Labs/Jetpack/JEP/17

From MozillaWiki
Jump to navigation Jump to search

JEP 17 - Page Mods

  • Champion: Aza Raskin <aza at mozilla dot com>
  • Implementer: David Dahl <ddahl at mozilla dot com>
  • Status: Implementing
  • Type: API Track
  • Created: 26 May 2009
  • Reference Implementation: None
  • Relevant Bugs: bug 501259
  • JEP Index

Introduction and Rationale

This JEP describes the syntactic sugar that makes it really easy to run code that modifies a page. It makes Greasemonkey-esque functionality easy to implement.

Proposal

Content scripts will live at jetpack.pageMods

Adding a new page modifier

jetpack.pageMods.add( callback, options );

Arguments:

  • callback: A function that modifies the page. It takes one argument, the document object of the page being loaded.
  • options:
    • matches: An array of match patterns describing which pages the content script should run on. If any of the match patterns matches a URL, the content script is run.