Compare Revisions

Modifying Web Pages Based on URL

Change Revisions

Revision 513561:

Revision 513561 by Delapouite on

Revision 514297:

Revision 514297 by groovecoder on

Title:
Modifying Web Pages Based on URL
Modifying Web Pages Based on URL
Slug:
Mozilla/Add-ons/SDK/Tutorials/Modifying_Web_Pages_Based_on_URL
Mozilla/Add-ons/SDK/Tutorials/Modifying_Web_Pages_Based_on_URL
Content:

Revision 513561
Revision 514297
nn83    <pre class="brush: js">
84// Import the page-mod API
85var pageMod = require("sdk/page-mod");
86// Import the self API
87var self = require("sdk/self");
88 
89// Create a page mod
90// It will run a script whenever a ".org" URL is loaded
91// The script replaces the page contents with a message
92pageMod.PageMod({
93  include: "*.org",
94  contentScriptFile: self.data.url("my-script.js")
95});
96</pre>
n90document.body.innerHTML = "&lt;h1&gt;Page matches ruleset&lt;/h1&n104$("body").html("&lt;h1&gt;Page matches ruleset&lt;/h1&gt;");
>gt;"; 
t106  contentScriptFile: self.data.url("my-script.js")t120  contentScriptFile: <span class="p">[</span>self.data.url("jquer
 >y-1.7.min.js")<span class="p">,</span> self.<span class="nx">data
 ></span><span class="p">.</span><span class="nx">url</span><span c
 >lass="p">(</span><span class="s2">"my-script.js"</span><span clas
 >s="p">)]</span>

Back to History