Skip to content
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------
Expand Down
12 changes: 10 additions & 2 deletions data/bountysource_client.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion data/popup/loader.js
Original file line number Diff line number Diff line change
@@ -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'];
Expand Down
18 changes: 13 additions & 5 deletions lib/bountysource_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/',
Expand All @@ -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) {
Expand Down Expand Up @@ -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 });
Expand Down Expand Up @@ -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);
});
Expand Down