Last active
September 10, 2020 22:06
-
-
Save rudiedirkx/1e739b4ed65c5a879710461c92e674bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const queue = []; | |
chrome.browserAction.onClicked.addListener(function(tab) { | |
var url = 'http://www.example.com/?x=' + String(Math.random()).substr(2); | |
queue.push(url); | |
console.log('queue', queue); | |
chrome.tabs.update({url}); | |
}); | |
chrome.runtime.onMessage.addListener(function(msg, sender, sendResponse) { | |
if (typeof msg.url == 'string') { | |
var i = queue.indexOf(msg.url); | |
sendResponse(i >= 0); | |
if (i >= 0) { | |
queue.splice(i, 1); | |
console.log('queue', queue); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chrome.runtime.sendMessage({url: location.href}, function(response) { | |
if (response === true) { | |
window.addEventListener('load', function(e) { | |
console.log('LOADED because opened, not always'); | |
}); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "SO 47973057", | |
"description": "SO 47973057", | |
"version": "1.0", | |
"permissions": [ "tabs", "<all_urls>" ], | |
"background": { | |
"scripts": [ "background.js" ] | |
}, | |
"content_scripts": [ | |
{ | |
"all_frames": true, | |
"js": [ "content.js" ], | |
"matches": [ "http://*/*", "https://*/*" ], | |
"run_at": "document_start" | |
} | |
], | |
"browser_action": { | |
"browser_style": false, | |
"default_title": "Open tab", | |
"default_icon": { | |
"38": "images/38x38.png", | |
"19": "images/19x19.png" | |
} | |
}, | |
"icons": { | |
"128": "images/128x128.png", | |
"64": "images/64x64.png", | |
"48": "images/48x48.png", | |
"32": "images/32x32.png", | |
"16": "images/16x16.png" | |
}, | |
"manifest_version": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment