Initial work to get working in Firefox
This commit is contained in:
@@ -1,50 +1,50 @@
|
||||
/* global chrome */
|
||||
|
||||
var config = require('../config');
|
||||
|
||||
/**
|
||||
* It changes the extension icon color.
|
||||
* Supported values are: 'red', 'white', 'gray' and ''.
|
||||
*
|
||||
* @param color
|
||||
*/
|
||||
function changeExtensionIcon(color) {
|
||||
|
||||
color = color ? color : '';
|
||||
|
||||
var path = null;
|
||||
|
||||
if (color !== '') {
|
||||
color = '-' + color;
|
||||
|
||||
path = './graphics/wakatime-logo-38' + color + '.png';
|
||||
|
||||
chrome.browserAction.setIcon({
|
||||
path: path
|
||||
});
|
||||
}
|
||||
|
||||
if (color === '') {
|
||||
chrome.storage.sync.get({
|
||||
theme: config.theme
|
||||
}, function (items) {
|
||||
if (items.theme == config.theme) {
|
||||
path = './graphics/wakatime-logo-38.png';
|
||||
|
||||
chrome.browserAction.setIcon({
|
||||
path: path
|
||||
});
|
||||
}
|
||||
else {
|
||||
path = './graphics/wakatime-logo-38-white.png';
|
||||
|
||||
chrome.browserAction.setIcon({
|
||||
path: path
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = changeExtensionIcon;
|
||||
/* global browser */
|
||||
|
||||
var config = require('../config');
|
||||
|
||||
/**
|
||||
* It changes the extension icon color.
|
||||
* Supported values are: 'red', 'white', 'gray' and ''.
|
||||
*
|
||||
* @param color
|
||||
*/
|
||||
function changeExtensionIcon(color) {
|
||||
|
||||
color = color ? color : '';
|
||||
|
||||
var path = null;
|
||||
|
||||
if (color !== '') {
|
||||
color = '-' + color;
|
||||
|
||||
path = './graphics/wakatime-logo-38' + color + '.png';
|
||||
|
||||
browser.browserAction.setIcon({
|
||||
path: path
|
||||
});
|
||||
}
|
||||
|
||||
if (color === '') {
|
||||
browser.storage.sync.get({
|
||||
theme: config.theme
|
||||
}).then(function (items) {
|
||||
if (items.theme == config.theme) {
|
||||
path = './graphics/wakatime-logo-38.png';
|
||||
|
||||
browser.browserAction.setIcon({
|
||||
path: path
|
||||
});
|
||||
}
|
||||
else {
|
||||
path = './graphics/wakatime-logo-38-white.png';
|
||||
|
||||
browser.browserAction.setIcon({
|
||||
path: path
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = changeExtensionIcon;
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
var config = require('../config');
|
||||
|
||||
// Helpers
|
||||
var changeExtensionIcon = require('./changeExtensionIcon');
|
||||
var changeExtensionTooltip = require('./changeExtensionTooltip');
|
||||
var in_array = require('./in_array');
|
||||
|
||||
/**
|
||||
* Sets the current state of the extension.
|
||||
*
|
||||
* @param state
|
||||
*/
|
||||
function changeExtensionState(state) {
|
||||
if (! in_array(state, config.states)) {
|
||||
throw new Error('Not a valid state!');
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case 'allGood':
|
||||
changeExtensionIcon(config.colors.allGood);
|
||||
changeExtensionTooltip(config.tooltips.allGood);
|
||||
break;
|
||||
case 'notLogging':
|
||||
changeExtensionIcon(config.colors.notLogging);
|
||||
changeExtensionTooltip(config.tooltips.notLogging);
|
||||
break;
|
||||
case 'notSignedIn':
|
||||
changeExtensionIcon(config.colors.notSignedIn);
|
||||
changeExtensionTooltip(config.tooltips.notSignedIn);
|
||||
break;
|
||||
case 'blacklisted':
|
||||
changeExtensionIcon(config.colors.notLogging);
|
||||
changeExtensionTooltip(config.tooltips.blacklisted);
|
||||
break;
|
||||
case 'whitelisted':
|
||||
changeExtensionIcon(config.colors.notLogging);
|
||||
changeExtensionTooltip(config.tooltips.whitelisted);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var config = require('../config');
|
||||
|
||||
// Helpers
|
||||
var changeExtensionIcon = require('./changeExtensionIcon');
|
||||
var changeExtensionTooltip = require('./changeExtensionTooltip');
|
||||
var in_array = require('./in_array');
|
||||
|
||||
/**
|
||||
* Sets the current state of the extension.
|
||||
*
|
||||
* @param state
|
||||
*/
|
||||
function changeExtensionState(state) {
|
||||
if (! in_array(state, config.states)) {
|
||||
throw new Error('Not a valid state!');
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case 'allGood':
|
||||
changeExtensionIcon(config.colors.allGood);
|
||||
changeExtensionTooltip(config.tooltips.allGood);
|
||||
break;
|
||||
case 'notLogging':
|
||||
changeExtensionIcon(config.colors.notLogging);
|
||||
changeExtensionTooltip(config.tooltips.notLogging);
|
||||
break;
|
||||
case 'notSignedIn':
|
||||
changeExtensionIcon(config.colors.notSignedIn);
|
||||
changeExtensionTooltip(config.tooltips.notSignedIn);
|
||||
break;
|
||||
case 'blacklisted':
|
||||
changeExtensionIcon(config.colors.notLogging);
|
||||
changeExtensionTooltip(config.tooltips.blacklisted);
|
||||
break;
|
||||
case 'whitelisted':
|
||||
changeExtensionIcon(config.colors.notLogging);
|
||||
changeExtensionTooltip(config.tooltips.whitelisted);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = changeExtensionState;
|
||||
@@ -1,22 +1,22 @@
|
||||
/* global chrome */
|
||||
|
||||
var config = require('../config');
|
||||
|
||||
/**
|
||||
* It changes the extension title
|
||||
*
|
||||
* @param text
|
||||
*/
|
||||
function changeExtensionTooltip(text) {
|
||||
|
||||
if (text === '') {
|
||||
text = config.name;
|
||||
}
|
||||
else {
|
||||
text = config.name + ' - ' + text;
|
||||
}
|
||||
|
||||
chrome.browserAction.setTitle({title: text});
|
||||
}
|
||||
|
||||
/* global browser */
|
||||
|
||||
var config = require('../config');
|
||||
|
||||
/**
|
||||
* It changes the extension title
|
||||
*
|
||||
* @param text
|
||||
*/
|
||||
function changeExtensionTooltip(text) {
|
||||
|
||||
if (text === '') {
|
||||
text = config.name;
|
||||
}
|
||||
else {
|
||||
text = config.name + ' - ' + text;
|
||||
}
|
||||
|
||||
browser.browserAction.setTitle({title: text});
|
||||
}
|
||||
|
||||
module.exports = changeExtensionTooltip;
|
||||
@@ -1,29 +1,29 @@
|
||||
/**
|
||||
* Creates an array from list using \n as delimiter
|
||||
* and checks if any element in list is contained in the url.
|
||||
*
|
||||
* @param url
|
||||
* @param list
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function contains(url, list) {
|
||||
var lines = list.split('\n');
|
||||
|
||||
for (var i = 0; i < lines.length; i ++) {
|
||||
|
||||
// Trim all lines from the list one by one
|
||||
var cleanLine = lines[i].trim();
|
||||
|
||||
// If by any chance one line in the list is empty, ignore it
|
||||
if(cleanLine === '') continue;
|
||||
|
||||
// If url contains the current line return true
|
||||
if (url.indexOf(cleanLine) > -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports = contains;
|
||||
/**
|
||||
* Creates an array from list using \n as delimiter
|
||||
* and checks if any element in list is contained in the url.
|
||||
*
|
||||
* @param url
|
||||
* @param list
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function contains(url, list) {
|
||||
var lines = list.split('\n');
|
||||
|
||||
for (var i = 0; i < lines.length; i ++) {
|
||||
|
||||
// Trim all lines from the list one by one
|
||||
var cleanLine = lines[i].trim();
|
||||
|
||||
// If by any chance one line in the list is empty, ignore it
|
||||
if(cleanLine === '') continue;
|
||||
|
||||
// If url contains the current line return true
|
||||
if (url.indexOf(cleanLine) > -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports = contains;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/**
|
||||
* Returns domain from given URL.
|
||||
*
|
||||
* @param url
|
||||
* @returns {string}
|
||||
*/
|
||||
function getDomainFromUrl(url) {
|
||||
var parts = url.split('/');
|
||||
|
||||
return parts[0] + "//" + parts[2];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns domain from given URL.
|
||||
*
|
||||
* @param url
|
||||
* @returns {string}
|
||||
*/
|
||||
function getDomainFromUrl(url) {
|
||||
var parts = url.split('/');
|
||||
|
||||
return parts[0] + "//" + parts[2];
|
||||
}
|
||||
|
||||
module.exports = getDomainFromUrl;
|
||||
@@ -1,18 +1,18 @@
|
||||
/**
|
||||
* Returns boolean if needle is found in haystack or not.
|
||||
*
|
||||
* @param needle
|
||||
* @param haystack
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function in_array(needle, haystack) {
|
||||
for (var i = 0; i < haystack.length; i ++) {
|
||||
if (needle == haystack[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns boolean if needle is found in haystack or not.
|
||||
*
|
||||
* @param needle
|
||||
* @param haystack
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function in_array(needle, haystack) {
|
||||
for (var i = 0; i < haystack.length; i ++) {
|
||||
if (needle == haystack[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports = in_array;
|
||||
Reference in New Issue
Block a user