Skip to content
This repository was archived by the owner on Nov 15, 2017. It is now read-only.

Commit dcb2040

Browse files
committed
this addresses #184
1 parent 561c64d commit dcb2040

File tree

4 files changed

+82
-35
lines changed

4 files changed

+82
-35
lines changed

background.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<script src="js/useragent.js"></script>
3030
<script src="js/contentscripthandlers.js"></script>
3131
<script src="js/start.js"></script>
32+
<script src="js/commands.js"></script>
3233
<script src="js/install.js"></script>
3334
</body>
3435
</html>

js/commands.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*******************************************************************************
2+
3+
httpswitchboard - a Chromium browser extension to black/white list requests.
4+
Copyright (C) 2014 Contributors to HTTP Switchboard
5+
6+
This program is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program. If not, see {http://www.gnu.org/licenses/}.
18+
19+
Home: https://github.com/gorhill/httpswitchboard
20+
*/
21+
22+
/******************************************************************************/
23+
24+
(function() {
25+
26+
/******************************************************************************/
27+
28+
var gotoDashboard = function(which) {
29+
chrome.runtime.sendMessage({
30+
what: 'gotoExtensionURL',
31+
url: 'dashboard.html#' + which
32+
});
33+
};
34+
35+
/******************************************************************************/
36+
37+
var onCommand = function(command) {
38+
switch ( command ) {
39+
case 'open-statistics':
40+
gotoDashboard('statistics');
41+
break;
42+
case 'open-ubiquitous-rules':
43+
gotoDashboard('ubiquitous-rules');
44+
break;
45+
case 'open-scoped-rules':
46+
gotoDashboard('scoped-rules');
47+
break;
48+
case 'open-settings':
49+
gotoDashboard('settings');
50+
break;
51+
}
52+
};
53+
54+
/******************************************************************************/
55+
56+
chrome.commands.onCommand.addListener(onCommand);
57+
58+
/******************************************************************************/
59+
60+
})();

js/start.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -173,17 +173,3 @@ function clearBrowserCacheCallback() {
173173
HTTPSB.asyncJobs.add('clearBrowserCache', null, clearBrowserCacheCallback, 15 * 60 * 1000, true);
174174

175175
/******************************************************************************/
176-
177-
chrome.commands.onCommand.addListener( function( command ) {
178-
var extensionURL;
179-
switch ( command ) {
180-
case 'open-statistics': extensionURL = 'dashboard.html#statistics'; break;
181-
case 'open-ubiquitous-rules': extensionURL = 'dashboard.html#ubiquitous-rules'; break;
182-
case 'open-scoped-rules': extensionURL = 'dashboard.html#scoped-rules'; break;
183-
case 'open-settings': extensionURL = 'dashboard.html#settings'; break;
184-
}
185-
if ( extensionURL ) {
186-
chrome.runtime.sendMessage( { what: 'gotoExtensionURL',
187-
url: extensionURL } );
188-
}
189-
});

manifest.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,29 @@
5757
"css/noop.css"
5858
],
5959
"commands": {
60-
"open-statistics": {
61-
"suggested_key": {
62-
"default": "Alt+S"
63-
},
64-
"description": "Open Statistics"
65-
},
60+
"open-statistics": {
61+
"suggested_key": {
62+
"default": "Alt+S"
63+
},
64+
"description": "Open Statistics"
65+
},
6666
"open-scoped-rules": {
67-
"suggested_key": {
68-
"default": "Alt+F"
69-
},
70-
"description": "Open Rule Manager"
71-
},
67+
"suggested_key": {
68+
"default": "Alt+F"
69+
},
70+
"description": "Open Rule manager"
71+
},
7272
"open-settings": {
73-
"suggested_key": {
74-
"default": "Alt+A"
75-
},
76-
"description": "Open Settings"
77-
},
73+
"suggested_key": {
74+
"default": "Alt+A"
75+
},
76+
"description": "Open Settings"
77+
},
7878
"open-ubiquitous-rules": {
79-
"suggested_key": {
80-
"default": "Ctrl+D"
81-
},
82-
"description": "Open Ubiquitous Rules"
83-
}
79+
"suggested_key": {
80+
"default": "Ctrl+D"
81+
},
82+
"description": "Open Ubiquitous rules"
83+
}
8484
}
8585
}

0 commit comments

Comments
 (0)