Fix: minor

This commit is contained in:
eight 2018-10-11 19:29:17 +08:00
parent fd5eeb4b81
commit c1bf9f57e9
5 changed files with 10 additions and 9 deletions

View File

@ -15,7 +15,7 @@ window.API_METHODS = Object.assign(window.API_METHODS || {}, {
editSave: styleManager.editSave, editSave: styleManager.editSave,
getTabUrlPrefix() { getTabUrlPrefix() {
return this.sender.tab.url.match(/^([\w-]+:\/\/[^/#]+)/)[1]; return this.sender.tab.url.match(/^([\w-]+:\/+[^/#]+)/)[1];
}, },
getStyleFromDB: id => getStyleFromDB: id =>
@ -254,12 +254,12 @@ if (chrome.contextMenus) {
createContextMenus(keys); createContextMenus(keys);
} }
// reinject content scripts when the extension is reloaded/updated. Firefox
// would handle this automatically.
if (!FIREFOX) { if (!FIREFOX) {
reinjectContentScripts(); reinjectContentScripts();
} }
// FIXME: implement exposeIframes in apply.js
// register hotkeys // register hotkeys
if (FIREFOX && browser.commands && browser.commands.update) { if (FIREFOX && browser.commands && browser.commands.update) {
const hotkeyPrefs = Object.keys(prefs.defaults).filter(k => k.startsWith('hotkey.')); const hotkeyPrefs = Object.keys(prefs.defaults).filter(k => k.startsWith('hotkey.'));
@ -305,7 +305,6 @@ function reinjectContentScripts() {
cs.matches.some(match => { cs.matches.some(match => {
if ((match === ALL_URLS || url.match(match)) && if ((match === ALL_URLS || url.match(match)) &&
(!url.startsWith('chrome') || url === NTP)) { (!url.startsWith('chrome') || url === NTP)) {
// TODO: add a `msg.pingTab` API?
msg.sendTab(id, {method: 'ping'}) msg.sendTab(id, {method: 'ping'})
.catch(() => false) .catch(() => false)
.then(pong => !pong && injectCS(cs, id)); .then(pong => !pong && injectCS(cs, id));

View File

@ -463,7 +463,7 @@ const styleManager = (() => {
} }
function getDomain(url) { function getDomain(url) {
return url.match(/^[\w-]+:\/\/(?:[\w:-]+@)?([^:/#]+)/)[1]; return url.match(/^[\w-]+:\/+(?:[\w:-]+@)?([^:/#]+)/)[1];
} }
function getUrlNoHash(url) { function getUrlNoHash(url) {

View File

@ -163,7 +163,7 @@
}); });
} }
function install({url, direct, downloaded, tab}, sender) { function install({url, direct, downloaded, tab}, sender = this.sender) {
tab = tab !== undefined ? tab : sender.tab; tab = tab !== undefined ? tab : sender.tab;
url = url || tab.url; url = url || tab.url;
if (direct && !downloaded) { if (direct && !downloaded) {

View File

@ -9,6 +9,8 @@
<link href="global.css" rel="stylesheet"> <link href="global.css" rel="stylesheet">
<link href="install-usercss/install-usercss.css" rel="stylesheet"> <link href="install-usercss/install-usercss.css" rel="stylesheet">
<script src="js/promisify.js"></script>
<script src="js/msg.js"></script>
<script src="js/messaging.js"></script> <script src="js/messaging.js"></script>
<script src="js/prefs.js"></script> <script src="js/prefs.js"></script>
<script src="js/dom.js"></script> <script src="js/dom.js"></script>

View File

@ -68,13 +68,13 @@
"matches": ["http://userstyles.org/*", "https://userstyles.org/*"], "matches": ["http://userstyles.org/*", "https://userstyles.org/*"],
"run_at": "document_start", "run_at": "document_start",
"all_frames": true, "all_frames": true,
"js": ["js/promisify.js", "js/msg.js", "content/install-hook-userstyles.js"] "js": ["content/install-hook-userstyles.js"]
}, },
{ {
"matches": ["https://openusercss.org/*", "https://openusercss.com/*"], "matches": ["https://openusercss.org/*", "https://openusercss.com/*"],
"run_at": "document_start", "run_at": "document_start",
"all_frames": false, "all_frames": false,
"js": ["js/promisify.js", "js/msg.js", "content/install-hook-openusercss.js"] "js": ["content/install-hook-openusercss.js"]
}, },
{ {
"matches": [ "matches": [
@ -98,7 +98,7 @@
], ],
"run_at": "document_idle", "run_at": "document_idle",
"all_frames": false, "all_frames": false,
"js": ["js/promisify.js", "js/msg.js", "content/install-hook-usercss.js"] "js": ["content/install-hook-usercss.js"]
} }
], ],
"browser_action": { "browser_action": {