diff --git a/README.md b/README.md index fbe4ff3..9775f5c 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Features * Add a +1 to issues without a spammy comment. * Automatically hide "+1" comments. (coming very soon!) * Supports GitHub, LaunchPad, Bugzilla, and Trac trackers +* Works with Chrome, Firefox, and Midori browsers Contributing ----------- diff --git a/data/bountysource_client.js b/data/bountysource_client.js index 1223c41..4f216a3 100644 --- a/data/bountysource_client.js +++ b/data/bountysource_client.js @@ -1,6 +1,14 @@ // Cross-browser helpers to be used in popups and content-scripts var BountysourceClient = { - browser: typeof(chrome)!=='undefined' ? 'chrome' : 'firefox', + browser: (function() { + if (typeof(chrome) !== "undefined") { + if (navigator.userAgent.indexOf("Midori") !== -1) { + return "midori"; + } + return "chrome"; + } + return "firefox"; + })(), // Computes path to extension hosted image imagePath: function(image) { @@ -20,7 +28,7 @@ var BountysourceClient = { callback = options.callback; delete options.callback; } - if (BountysourceClient.browser === 'chrome') { + if (BountysourceClient.browser === 'chrome' || BountysourceClient.browser === 'midori') { chrome.runtime.sendMessage(options, callback); } else if (BountysourceClient.browser === 'firefox') { options.callback_str = "callback_" + (new Date()).getTime(); diff --git a/data/popup/loader.js b/data/popup/loader.js index 18f5161..651df4e 100644 --- a/data/popup/loader.js +++ b/data/popup/loader.js @@ -1,4 +1,4 @@ -// GOOGLE CHROME - load javascript dependencies via script tag +// GOOGLE CHROME / MIDORI - load javascript dependencies via script tag // FIREFOX - do nothing... these are loaded via bountysource_server.js (function() { var scripts = ['../bountysource_client.js', 'application.js']; diff --git a/lib/bountysource_server.js b/lib/bountysource_server.js index 39bc55d..d15d479 100644 --- a/lib/bountysource_server.js +++ b/lib/bountysource_server.js @@ -9,7 +9,15 @@ if (typeof(localStorage) === 'undefined') { // global functions var BountysourceServer = { - browser: typeof(chrome)!=='undefined' ? 'chrome' : 'firefox', + browser: (function() { + if (typeof(chrome) !== 'undefined') { + if (typeof(navigator) !== 'undefined' && navigator.userAgent.indexOf('Midori') !== -1) { + return 'midori'; + } + return 'chrome'; + } + return 'firefox'; + })(), www_base: 'https://www.bountysource.com/', api_base: 'https://api.bountysource.com/', @@ -23,7 +31,7 @@ var BountysourceServer = { // listens for messages from BountysourceClient start_register_message_handler: function() { - if (BountysourceServer.browser === 'chrome') { + if (BountysourceServer.browser === 'chrome' || BountysourceServer.browser === 'midori') { chrome.runtime.onMessage.addListener(function(options, sender, sendResponse) { BountysourceServer.get_access_token(function(access_token) { @@ -132,9 +140,9 @@ var BountysourceServer = { localStorage['installed'] = 'yes'; var post_install_url = BountysourceServer.www_url('/extension/installed'); - if (BountysourceServer.browser === 'chrome') { + if (BountysourceServer.browser === 'chrome' || BountysourceServer.browser === 'midori') { chrome.tabs.query({ active: true }, function(tabs) { - if (tabs[0] && (tabs[0].url.indexOf(BountysourceServer.www_base) === 0) || (tabs[0].url.indexOf('https://chrome.google.com/') === 0)) { + if (tabs[0] && (tabs[0].url.indexOf(BountysourceServer.www_base) === 0) || (tabs[0].url.indexOf('https://chrome.google.com/') === 0) || (tabs[0].url.indexOf('https://extensions.midori-browser.org/') === 0)) { chrome.tabs.update(tabs[0].id, { url: post_install_url }); } else { chrome.tabs.create({ url: post_install_url }); @@ -184,7 +192,7 @@ var BountysourceServer = { // lookup access_token cookie from www.bountysource.com get_access_token: function(callback) { - if (BountysourceServer.browser === 'chrome') { + if (BountysourceServer.browser === 'chrome' || BountysourceServer.browser === 'midori') { chrome.cookies.get({ url: BountysourceServer.www_base, name: 'v2_access_token' }, function(cookies) { callback(cookies ? JSON.parse(decodeURIComponent(cookies.value)) : null); });