diff --git a/extension/js/background.js b/extension/js/background.js index c5b223a..768b7d3 100644 --- a/extension/js/background.js +++ b/extension/js/background.js @@ -31,7 +31,7 @@ */ /*jshint eqeqeq:true, forin:true, strict:true */ -/*global chrome, console */ +/*global browser, chrome, console */ (function () { @@ -47,6 +47,10 @@ TYPE_NULL = 6 ; + function getBrowser() { + return typeof browser !== 'undefined' ? browser : chrome; + } + // Utility functions function removeComments (str) { str = ('__' + str + '__').split(''); @@ -395,7 +399,7 @@ } // Listen for requests from content pages wanting to set up a port - chrome.extension.onConnect.addListener(function(port) { + getBrowser().runtime.onConnect.addListener(function(port) { if (port.name !== 'jf') { console.log('JSON Formatter error - unknown port name '+port.name, port) ; diff --git a/extension/js/content.js b/extension/js/content.js index b930379..96a1812 100644 --- a/extension/js/content.js +++ b/extension/js/content.js @@ -31,12 +31,16 @@ */ /*jshint eqeqeq:true, forin:true, strict:true */ -/*global chrome, console */ +/*global browser, chrome, console */ (function() { "use strict" ; + function getBrowser() { + return typeof browser !== 'undefined' ? browser : chrome; + } + var jfContent, pre, jfStyleEl, @@ -51,7 +55,7 @@ // Open the port "jf" now, ready for when we need it // console.time('established port') ; - port = chrome.extension.connect({name: 'jf'}) ; + port = getBrowser().runtime.connect({name: 'jf'}) ; // Add listener to receive response from BG when ready port.onMessage.addListener( function (msg) { diff --git a/extension/manifest.json b/extension/manifest.json index da90eb7..c9a62e6 100644 --- a/extension/manifest.json +++ b/extension/manifest.json @@ -1,16 +1,18 @@ { "name": "JSON Formatter", - "version": "0.6.0", + "version": "0.6.1", "manifest_version": 2, "description": "Makes JSON easy to read. Open source.", - "homepage_url": "https://github.com/callumlocke/json-formatter", - "minimum_chrome_version": "21", + "homepage_url": "https://github.com/nikrolls/json-formatter", + "author": "Nik Rolls, Callum Locke", + "minimum_edge_version": "38", "icons": { "128": "icons/128.png", "32": "icons/32.png" }, "background": { - "scripts": ["js/background.js"] + "scripts": ["js/background.js"], + "persistent": false }, "content_scripts": [ { "matches": [""], "js": ["js/content.js"], "run_at": "document_start" }