Skip to content

Instantly share code, notes, and snippets.

@bwinton
Created December 8, 2014 20:34
Show Gist options
  • Select an option

  • Save bwinton/54da2a0b4bf01d205039 to your computer and use it in GitHub Desktop.

Select an option

Save bwinton/54da2a0b4bf01d205039 to your computer and use it in GitHub Desktop.
How does this look to everyone?
diff --git a/index.html b/index.html
index d23efde..9bba611 100755
--- a/index.html
+++ b/index.html
@@ -36,5 +36,12 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<script src="js/vendor/jquery/dist/jquery.min.js" charset="utf-8"></script>
<script src="js/main.js"></script>
+ <script>
+ window.addEventListener("message", function (event) {
+ if (event.data === 'whimsy:enabled') {
+ console.log("Whimsy!", event.data);
+ }
+ }, false);
+ </script>
</body>
</html>
diff --git a/lib/main.js b/lib/main.js
index 37df5e1..133734f 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -12,6 +12,7 @@
'use strict';
+var pageMod = require('sdk/page-mod');
var prefs = require('sdk/simple-prefs');
var { Cu } = require('chrome');
Cu.import('resource://gre/modules/UITelemetry.jsm');
@@ -104,6 +105,11 @@ exports.main = function () {
});
}
+ pageMod.PageMod({
+ include: '*',
+ contentScript: 'window.postMessage("whimsy:enabled", "*")'
+ });
+
};
exports.onUnload = function () {
@mikeconley

Copy link
Copy Markdown

Ship it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment