Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions extension/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/

/*jshint eqeqeq:true, forin:true, strict:true */
/*global chrome, console */
/*global browser, chrome, console */

(function () {

Expand All @@ -47,6 +47,10 @@
TYPE_NULL = 6
;

function getBrowser() {
return typeof browser !== 'undefined' ? browser : chrome;
}

// Utility functions
function removeComments (str) {
str = ('__' + str + '__').split('');
Expand Down Expand Up @@ -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) ;
Expand Down
8 changes: 6 additions & 2 deletions extension/js/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down
10 changes: 6 additions & 4 deletions extension/manifest.json
Original file line number Diff line number Diff line change
@@ -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": true
},
"content_scripts": [
{ "matches": ["<all_urls>"], "js": ["js/content.js"], "run_at": "document_start" }
Expand Down