Skip to content

Instantly share code, notes, and snippets.

@Gozala
Created January 6, 2011 12:44
Show Gist options
  • Save Gozala/767840 to your computer and use it in GitHub Desktop.
Save Gozala/767840 to your computer and use it in GitHub Desktop.
Implementing same with a current API.
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
});
}
}
});
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