Created
January 6, 2011 12:44
-
-
Save Gozala/767840 to your computer and use it in GitHub Desktop.
Implementing same with a current API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var pageMod = require("page-mod"); | |
| pageMod.PageMod({ | |
| include: "*.org", | |
| contentScriptWhen: 'ready', | |
| contentScript: 'postMessage({ handler: "reportLocation", data: window.location.href });', | |
| onMessage: function({ handler, data }) { this.messageHandlers[handler](data); }, | |
| messageHandlers:{ | |
| reportLocation: function(location) { | |
| require("notifications").notify({ | |
| title: "Page Location Notification", | |
| text: "You are on the following page: " + location | |
| }); | |
| } | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var pageMod = require("page-mod"); | |
| pageMod.PageMod({ | |
| include: "*.org", | |
| contentScriptWhen: 'ready', | |
| contentScript: 'reportLocation(window.location.href);' | |
| messageHandlers:{ | |
| reportLocation: function(location) { | |
| require("notifications").notify({ | |
| title: "Page Location Notification", | |
| text: "You are on the following page: " + location | |
| }); | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment