Confirmed users
161
edits
mNo edit summary |
|||
Line 1: | Line 1: | ||
This is an | This is an alternative version of [[Labs/Jetpack/Reboot/JEP/107]] ('''page mods'''). | ||
---- | |||
There are two common ways to modify web pages from the browser: | There are two common ways to modify web pages from the browser: | ||
* by specifying custom CSS to apply to specific pages, sites, or all web content. (This is what [https://addons.mozilla.org/en-US/firefox/addon/2108 Stylish extension] does.) | * by specifying custom CSS to apply to specific pages, sites, or all web content. (This is what [https://addons.mozilla.org/en-US/firefox/addon/2108 Stylish extension] does.) | ||
Line 62: | Line 63: | ||
** The specified callbacks are called with a single <code>wrappedWindow</code> parameter -- the content's <code>window</code> object wrapped in an XPCNativeWrapper. The callback's <code>this</code> is the page mod object ('''TBD''' not currently implemented). It goes without saying that with this syntax the callbacks are run in the calling module's scope, not in the content page's scope. | ** The specified callbacks are called with a single <code>wrappedWindow</code> parameter -- the content's <code>window</code> object wrapped in an XPCNativeWrapper. The callback's <code>this</code> is the page mod object ('''TBD''' not currently implemented). It goes without saying that with this syntax the callbacks are run in the calling module's scope, not in the content page's scope. | ||
Creating a <code>ScriptMod</code> instance automatically enables it | Creating a <code>ScriptMod</code> instance automatically [[#scriptMod-enable|enables it]]. | ||
===== ISSUE: What format should be chosen for <code>include</code> rules? ===== | ===== ISSUE: What format should be chosen for <code>include</code> rules? ===== | ||
Line 90: | Line 87: | ||
==== <code>ScriptMod</code> APIs ==== | ==== <code>ScriptMod</code> APIs ==== | ||
* Instance properties | |||
** <code id="scriptMod-disable">scriptMod.disable()</code>. Call this to stop a script mod from running on further pages. This does not undo the mod's effects on already loaded pages. | |||
** <code id="scriptMod-enable">scriptMod.enable()</code>. Enabling a script mod makes it take effect on any matching pages that start to load after the script mod is enabled. Enabling a script mod does not apply it to existing matching pages. | |||
* Helper functions available as properties on the <code>ScriptMod</code> constructor | |||
** <code>ScriptMod.onDOMContentLoaded(''callback'')</code> - when passed as one of the <code>scripts</code> in the <code>ScriptMod</code> constructor options, calls the <code>callback</code> on matching pages when their DOM is available (on the [http://wiki.greasespot.net/DOMContentLoaded <code>DOMContentLoaded</code>] event). | |||
=== Style mods === | === Style mods === | ||
TBD | TBD | ||