mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-16 06:18:35 +02:00
Replace var with let in examples (#484)
* Replace var with let in examples store-collected-images/webextension-plain/deps/uuidv4.js * Reverted third–party code
This commit is contained in:
@@ -8,13 +8,13 @@ in the console, but the alarm will still go off after 6 seconds
|
||||
* if you package the extension and install it, then the alarm will go off after
|
||||
a minute.
|
||||
*/
|
||||
var DELAY = 0.1;
|
||||
var CATGIFS = "https://giphy.com/explore/cat";
|
||||
let DELAY = 0.1;
|
||||
let CATGIFS = "https://giphy.com/explore/cat";
|
||||
|
||||
/*
|
||||
Restart alarm for the currently active tab, whenever background.js is run.
|
||||
*/
|
||||
var gettingActiveTab = browser.tabs.query({active: true, currentWindow: true});
|
||||
let gettingActiveTab = browser.tabs.query({active: true, currentWindow: true});
|
||||
gettingActiveTab.then((tabs) => {
|
||||
restartAlarm(tabs[0].id);
|
||||
});
|
||||
@@ -26,7 +26,7 @@ browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
|
||||
if (!changeInfo.url) {
|
||||
return;
|
||||
}
|
||||
var gettingActiveTab = browser.tabs.query({active: true, currentWindow: true});
|
||||
let gettingActiveTab = browser.tabs.query({active: true, currentWindow: true});
|
||||
gettingActiveTab.then((tabs) => {
|
||||
if (tabId == tabs[0].id) {
|
||||
restartAlarm(tabId);
|
||||
@@ -48,7 +48,7 @@ then set a new alarm for the given tab.
|
||||
function restartAlarm(tabId) {
|
||||
browser.pageAction.hide(tabId);
|
||||
browser.alarms.clearAll();
|
||||
var gettingTab = browser.tabs.get(tabId);
|
||||
let gettingTab = browser.tabs.get(tabId);
|
||||
gettingTab.then((tab) => {
|
||||
if (tab.url != CATGIFS) {
|
||||
browser.alarms.create("", {delayInMinutes: DELAY});
|
||||
@@ -60,7 +60,7 @@ function restartAlarm(tabId) {
|
||||
On alarm, show the page action.
|
||||
*/
|
||||
browser.alarms.onAlarm.addListener((alarm) => {
|
||||
var gettingActiveTab = browser.tabs.query({active: true, currentWindow: true});
|
||||
let gettingActiveTab = browser.tabs.query({active: true, currentWindow: true});
|
||||
gettingActiveTab.then((tabs) => {
|
||||
browser.pageAction.show(tabs[0].id);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user