User:Eleanorg/Thematic1.1/control opacity using jQuery plugin

From XPUB & Lens-Based wiki
< User:Eleanorg
Revision as of 18:33, 10 December 2011 by Eleanorg (talk | contribs) (Created page with "This Chrome plugin changes the opacity of web pages with a single line of jQuery. Eventually the extension will be plugged into my python script, which will return a dynamic opac...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This Chrome plugin changes the opacity of web pages with a single line of jQuery. Eventually the extension will be plugged into my python script, which will return a dynamic opacity value based on the number of hops in that webpage's traceroute.

It follows the basic Chrome extension pattern of being made up of a manifest.json file (containing metadata) and a .js file containing the actual code. In this case, jQuery is also stored locally in jquery.js.

contentscript.js

 $("body").css({ opacity: 0.2 });

manifest.json

Note that jQuery is stored locally as jquery.js, and this file points to the actual code which is stored in contentscript.js:

{
  "name": "traceroute1",
  "version": "1.0",
  "description": "changes the opacity of web pages",
  "browser_action": {
    "default_icon": "icon.png"
  },
  "permissions": ["history"],
  "content_scripts": [
    {
      "matches": ["*://*/*"],
      "js": ["jquery.js", "contentscript.js"],
      "run_at": "document_end"
    }
  ]
}