Skip to content

Commit

Permalink
Shortcut Added !
Browse files Browse the repository at this point in the history
  • Loading branch information
maximelebreton committed Oct 23, 2013
1 parent e18c489 commit b5fe0a6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
35 changes: 26 additions & 9 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var prefs;
var contextMenuId = null;

var chromeContentSettings = chrome.contentSettings;
/* currently (chrome 16), infobars is not implemented (only experimental...) */
/* currently, infobars is not implemented (only experimental...) */
var chromeInfobars = chrome.infobars;


Expand Down Expand Up @@ -53,6 +53,14 @@ if(chromeContentSettings) {

chrome.browserAction.onClicked.addListener(changeSettings);


chrome.commands.onCommand.addListener(function(command) {
if (command == "toggle-qjs") {
changeSettings();
}
});


} else {
chrome.browserAction.onClicked.addListener(openJsPanel.call());
}
Expand All @@ -75,12 +83,13 @@ function getSettings() {
function(details) {
//console.info("Current tab settings : "+url);
url ? matchForbiddenOrigin = url.match(forbiddenOrigin,'') : matchForbiddenOrigin = true;
matchForbiddenOrigin ? updateIcon("inactive") : updateIcon(details.setting);
matchForbiddenOrigin ? updateIcon("inactive") : updateIcon(details.setting);
});
});
}

function changeSettings() {

if (!matchForbiddenOrigin) {
chromeContentSettings.javascript.get({
'primaryUrl': url,
Expand All @@ -98,15 +107,17 @@ function changeSettings() {
'primaryPattern': pattern,
'setting': newSetting,
'scope': (incognito ? 'incognito_session_only' : 'regular')
});

updateIcon(newSetting);
}, function() {

if (prefs.autoRefresh) {
chrome.tabs.reload(tabId);
}
updateIcon(newSetting);

setLocalStorageRule(pattern, newSetting);
if (prefs.autoRefresh) {
chrome.tabs.reload(tabId);
}

setLocalStorageRule(pattern, newSetting);

});

//console.info("javascript is now "+newSetting+"ed on "+pattern);
}
Expand All @@ -125,6 +136,7 @@ function changeSettings() {
}

}

}


Expand All @@ -149,6 +161,9 @@ function setLocalStorageRule(pattern, newSetting) {
}

if (!keyExist) {

// to do : keep only block, only allow or both

rules.push({
'primaryPattern': pattern,
'setting': newSetting,
Expand All @@ -166,6 +181,8 @@ function importRules(localStorageRules) {

var rules = localStorageRules;

// todo : delete spaces

if (rules.length) {
for(i = 0; i < rules.length; i++) {

Expand Down
10 changes: 9 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ "name" : "Quick Javascript Switcher"
, "version" : "1.3.0"
, "version" : "1.3.1"
, "minimum_chrome_version": "16.0"
, "manifest_version" : 2
, "homepage_url" : "https://github.com/maximelebreton/quick-javascript-switcher"
Expand Down Expand Up @@ -28,5 +28,13 @@
{ "page": "background.html"
}
, "options_page" : "options.html"

, "commands": {
"toggle-qjs": {
"suggested_key": { "default": "Alt+Shift+Q" },
"description": "Toggle JavaScript"
}
}

}

2 changes: 1 addition & 1 deletion updates.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='njccaledehimfapjafihbdalapfcfjak'>
<updatecheck codebase='https://github.com/downloads/maximelebreton/quick-javascript-switcher/quick-javascript-switcher.crx' version='1.3.0' prodversionmin='16.0' />
<updatecheck codebase='https://github.com/downloads/maximelebreton/quick-javascript-switcher/quick-javascript-switcher.crx' version='1.3.1' prodversionmin='16.0' />
</app>
</gupdate>

1 comment on commit b5fe0a6

@Owyn
Copy link

@Owyn Owyn commented on b5fe0a6 Aug 2, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There appears no option to change shortcut in settings.
Using Quick Javascript Switcher 1.3.2 from the store.

Please sign in to comment.