-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
22 lines (20 loc) · 787 Bytes
/
background.js
File metadata and controls
22 lines (20 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(tab.id, {file: "bookmarklet.js"})
});
chrome.browserAction.onClicked.addListener(tab => {
if (!tab.url) return;
chrome.storage.sync.get('savedApi', ({savedApi}) => {
chrome.tabs.create({
url: `https://www.webpagetest.org/runtest.php?url=${encodeURIComponent(tab.url)}&k=${savedApi}`,
index: tab.index + 1,
openerTabId: tab.id,
});
});
});
chrome.runtime.onInstalled.addListener(function (object) {
if (chrome.runtime.OnInstalledReason.INSTALL === object.reason) {
chrome.tabs.create({url:chrome.extension.getURL("welcome.html")}, function (tab) {
console.log("New tab launched with instructions to use the extension");
});
}
});