Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Commit

Permalink
Command keys to open up the options and test pages
Browse files Browse the repository at this point in the history
  • Loading branch information
keithbowes committed Sep 3, 2017
1 parent b793f4e commit 358cc37
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
10 changes: 10 additions & 0 deletions webext/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ var Background = {

return {requestHeaders: e.requestHeaders};
},
command: function(cmd)
{
if ('open-options' == cmd)
browser.runtime.openOptionsPage();
else if ('open-test' == cmd)
browser.browserAction.getPopup({}).then(function(url) { window.open(url); }, null);
},
updated: function(tabId, changeInfo, tab)
{
Background.userAgent.set();
Expand All @@ -33,6 +40,8 @@ var Background = {
let pval = Options.hosts[host];
if (host && pval)
{
browser.browserAction.setTitle({title: Options.hosts[host].description});

if (pval = pval[prop.toLowerCase()])
{
return pval;
Expand Down Expand Up @@ -66,6 +75,7 @@ var Background = {
}
};

browser.commands.onCommand.addListener(Background.events.command);
browser.tabs.onActivated.addListener(Background.events.activated);
browser.tabs.onUpdated.addListener(Background.events.updated);
browser.webRequest.onBeforeSendHeaders.addListener(Background.events.beforeSendHeaders, {urls: ["<all_urls>"]}, ["blocking", "requestHeaders"]);
Expand Down
13 changes: 13 additions & 0 deletions webext/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@
"scripts": ["common.js", "options.js", "background.js"]
},

"commands": {
"open-options": {
"suggested_key": {
"default": "Alt+O"
}
},
"open-test": {
"suggested_key": {
"default": "Ctrl+Shift+U"
}
}
},

"icons": {
"16": "icons/default-16.png",
"32": "icons/logo-32.png"
Expand Down
1 change: 1 addition & 0 deletions webext/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ var OptionsPage = {
var ualist = document.createElement('select');
ualist.id = 'ua-list';
ualist.size = 10;
ualist.tabIndex = 2;
uacell.appendChild(ualist);
},
downloadList: function(e)
Expand Down
16 changes: 8 additions & 8 deletions webext/options.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<table id="uaswitch-options">
<tr>
<td><label for="ua-file"/></td>
<td><input type="text" id="ua-file"/></td>
<td><input type="button" id="dl-ua"/></td>
<td><input type="text" id="ua-file" tabindex="7"/></td>
<td><input type="button" id="dl-ua" tabindex="8"/></td>
</tr>
<tr>
<td id="hosts-cell"/>
Expand All @@ -23,18 +23,18 @@
<table>
<tr>
<td>
<input type="button" id="move-up"/>
<input type="button" id="move-up" tabindex="4"/>
</td>
<td>
<input type="button" id="move-down"/>
<input type="button" id="move-down" tabindex="5"/>
</td>
</tr>
<tr>
<td>
<input type="button" id="add-new"/>
<input type="button" id="add-new" tabindex="1"/>
</td>
<td>
<input type="button" id="delete"/>
<input type="button" id="delete" tabindex="3"/>
</td>
</tr>
</table>
Expand All @@ -45,8 +45,8 @@
<td/>
<td>
<div id="command-shelf">
<input type="button" id="save"/>
<input type="button" id="reset"/>
<input type="button" id="save" tabindex="6"/>
<input type="button" id="reset" tabindex="9"/>
</div>
</td>
</tr>
Expand Down

0 comments on commit 358cc37

Please sign in to comment.