0 is a valid tab id
This commit is contained in:
parent
ea277bcf4c
commit
6aef6cdcd7
|
@ -85,7 +85,8 @@ var usercssHelper = (() => {
|
|||
return wrapReject(openURL({
|
||||
url: '/install-usercss.html' +
|
||||
'?updateUrl=' + encodeURIComponent(url) +
|
||||
'&tabId=' + (direct ? -tab.id : tab.id),
|
||||
'&tabId=' + tab.id +
|
||||
(direct ? '&direct=yes' : ''),
|
||||
index: tab.index + 1,
|
||||
openerTabId: tab.id,
|
||||
}));
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
const tabId = Number(params.get('tabId'));
|
||||
let port;
|
||||
|
||||
if (tabId < 0) {
|
||||
if (params.has('direct')) {
|
||||
$('.live-reload').remove();
|
||||
getCodeDirectly();
|
||||
} else {
|
||||
|
@ -327,7 +327,7 @@
|
|||
function getCodeDirectly() {
|
||||
// FF applies page CSP even to content scripts, https://bugzil.la/1267027
|
||||
// To circumvent that, the bg process downloads the code directly
|
||||
const key = 'tempUsercssCode' + (-tabId);
|
||||
const key = 'tempUsercssCode' + tabId;
|
||||
chrome.storage.local.get(key, data => {
|
||||
const code = data && data[key];
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ function notifyAllTabs(msg) {
|
|||
}
|
||||
// notify background page and all open popups
|
||||
if (affectsSelf) {
|
||||
msg.tabId = null;
|
||||
msg.tabId = undefined;
|
||||
sendMessage(msg, ignoreChromeError);
|
||||
}
|
||||
}
|
||||
|
@ -144,8 +144,8 @@ function sendMessage(msg, callback) {
|
|||
- enabled by passing a second param
|
||||
*/
|
||||
const {tabId, frameId} = msg;
|
||||
const fn = tabId ? chrome.tabs.sendMessage : chrome.runtime.sendMessage;
|
||||
const args = tabId ? [tabId, msg, {frameId}] : [msg];
|
||||
const fn = tabId >= 0 ? chrome.tabs.sendMessage : chrome.runtime.sendMessage;
|
||||
const args = tabId >= 0 ? [tabId, msg, {frameId}] : [msg];
|
||||
if (callback) {
|
||||
fn(...args, callback);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user