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:
@@ -1,4 +1,4 @@
|
|||||||
var myWindowId;
|
let myWindowId;
|
||||||
const contentBox = document.querySelector("#content");
|
const contentBox = document.querySelector("#content");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ function toggleCSS(tab) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var gettingTitle = browser.pageAction.getTitle({tabId: tab.id});
|
let gettingTitle = browser.pageAction.getTitle({tabId: tab.id});
|
||||||
gettingTitle.then(gotTitle);
|
gettingTitle.then(gotTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ function initializePageAction(tab) {
|
|||||||
/*
|
/*
|
||||||
When first loaded, initialize the page action for all tabs.
|
When first loaded, initialize the page action for all tabs.
|
||||||
*/
|
*/
|
||||||
var gettingAllTabs = browser.tabs.query({});
|
let gettingAllTabs = browser.tabs.query({});
|
||||||
gettingAllTabs.then((tabs) => {
|
gettingAllTabs.then((tabs) => {
|
||||||
for (let tab of tabs) {
|
for (let tab of tabs) {
|
||||||
initializePageAction(tab);
|
initializePageAction(tab);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
var currentTab;
|
let currentTab;
|
||||||
var currentBookmark;
|
let currentBookmark;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Updates the browserAction icon to reflect whether the current page
|
* Updates the browserAction icon to reflect whether the current page
|
||||||
@@ -42,8 +42,8 @@ browser.browserAction.onClicked.addListener(toggleBookmark);
|
|||||||
function updateActiveTab(tabs) {
|
function updateActiveTab(tabs) {
|
||||||
|
|
||||||
function isSupportedProtocol(urlString) {
|
function isSupportedProtocol(urlString) {
|
||||||
var supportedProtocols = ["https:", "http:", "ftp:", "file:"];
|
let supportedProtocols = ["https:", "http:", "ftp:", "file:"];
|
||||||
var url = document.createElement('a');
|
let url = document.createElement('a');
|
||||||
url.href = urlString;
|
url.href = urlString;
|
||||||
return supportedProtocols.indexOf(url.protocol) != -1;
|
return supportedProtocols.indexOf(url.protocol) != -1;
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ function updateActiveTab(tabs) {
|
|||||||
if (tabs[0]) {
|
if (tabs[0]) {
|
||||||
currentTab = tabs[0];
|
currentTab = tabs[0];
|
||||||
if (isSupportedProtocol(currentTab.url)) {
|
if (isSupportedProtocol(currentTab.url)) {
|
||||||
var searching = browser.bookmarks.search({url: currentTab.url});
|
let searching = browser.bookmarks.search({url: currentTab.url});
|
||||||
searching.then((bookmarks) => {
|
searching.then((bookmarks) => {
|
||||||
currentBookmark = bookmarks[0];
|
currentBookmark = bookmarks[0];
|
||||||
updateIcon();
|
updateIcon();
|
||||||
@@ -63,7 +63,7 @@ function updateActiveTab(tabs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var gettingActiveTab = browser.tabs.query({active: true, currentWindow: true});
|
let gettingActiveTab = browser.tabs.query({active: true, currentWindow: true});
|
||||||
gettingActiveTab.then(updateTab);
|
gettingActiveTab.then(updateTab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
* if you package the extension and install it, then the alarm will go off after
|
||||||
a minute.
|
a minute.
|
||||||
*/
|
*/
|
||||||
var DELAY = 0.1;
|
let DELAY = 0.1;
|
||||||
var CATGIFS = "https://giphy.com/explore/cat";
|
let CATGIFS = "https://giphy.com/explore/cat";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Restart alarm for the currently active tab, whenever background.js is run.
|
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) => {
|
gettingActiveTab.then((tabs) => {
|
||||||
restartAlarm(tabs[0].id);
|
restartAlarm(tabs[0].id);
|
||||||
});
|
});
|
||||||
@@ -26,7 +26,7 @@ browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
|
|||||||
if (!changeInfo.url) {
|
if (!changeInfo.url) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var gettingActiveTab = browser.tabs.query({active: true, currentWindow: true});
|
let gettingActiveTab = browser.tabs.query({active: true, currentWindow: true});
|
||||||
gettingActiveTab.then((tabs) => {
|
gettingActiveTab.then((tabs) => {
|
||||||
if (tabId == tabs[0].id) {
|
if (tabId == tabs[0].id) {
|
||||||
restartAlarm(tabId);
|
restartAlarm(tabId);
|
||||||
@@ -48,7 +48,7 @@ then set a new alarm for the given tab.
|
|||||||
function restartAlarm(tabId) {
|
function restartAlarm(tabId) {
|
||||||
browser.pageAction.hide(tabId);
|
browser.pageAction.hide(tabId);
|
||||||
browser.alarms.clearAll();
|
browser.alarms.clearAll();
|
||||||
var gettingTab = browser.tabs.get(tabId);
|
let gettingTab = browser.tabs.get(tabId);
|
||||||
gettingTab.then((tab) => {
|
gettingTab.then((tab) => {
|
||||||
if (tab.url != CATGIFS) {
|
if (tab.url != CATGIFS) {
|
||||||
browser.alarms.create("", {delayInMinutes: DELAY});
|
browser.alarms.create("", {delayInMinutes: DELAY});
|
||||||
@@ -60,7 +60,7 @@ function restartAlarm(tabId) {
|
|||||||
On alarm, show the page action.
|
On alarm, show the page action.
|
||||||
*/
|
*/
|
||||||
browser.alarms.onAlarm.addListener((alarm) => {
|
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) => {
|
gettingActiveTab.then((tabs) => {
|
||||||
browser.pageAction.show(tabs[0].id);
|
browser.pageAction.show(tabs[0].id);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var registered = null;
|
let registered = null;
|
||||||
|
|
||||||
async function registerScript(message) {
|
async function registerScript(message) {
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ function createOptions(node, identity) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var div = document.getElementById('identity-list');
|
let div = document.getElementById('identity-list');
|
||||||
|
|
||||||
if (browser.contextualIdentities === undefined) {
|
if (browser.contextualIdentities === undefined) {
|
||||||
div.innerText = 'browser.contextualIdentities not available. Check that the privacy.userContext.enabled pref is set to true, and reload the add-on.';
|
div.innerText = 'browser.contextualIdentities not available. Check that the privacy.userContext.enabled pref is set to true, and reload the add-on.';
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ function getActiveTab() {
|
|||||||
function cookieUpdate() {
|
function cookieUpdate() {
|
||||||
getActiveTab().then((tabs) => {
|
getActiveTab().then((tabs) => {
|
||||||
// get any previously set cookie for the current tab
|
// get any previously set cookie for the current tab
|
||||||
var gettingCookies = browser.cookies.get({
|
let gettingCookies = browser.cookies.get({
|
||||||
url: tabs[0].url,
|
url: tabs[0].url,
|
||||||
name: "bgpicker"
|
name: "bgpicker"
|
||||||
});
|
});
|
||||||
gettingCookies.then((cookie) => {
|
gettingCookies.then((cookie) => {
|
||||||
if (cookie) {
|
if (cookie) {
|
||||||
var cookieVal = JSON.parse(cookie.value);
|
let cookieVal = JSON.parse(cookie.value);
|
||||||
browser.tabs.sendMessage(tabs[0].id, {image: cookieVal.image});
|
browser.tabs.sendMessage(tabs[0].id, {image: cookieVal.image});
|
||||||
browser.tabs.sendMessage(tabs[0].id, {color: cookieVal.color});
|
browser.tabs.sendMessage(tabs[0].id, {color: cookieVal.color});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
browser.runtime.onMessage.addListener(updateBg);
|
browser.runtime.onMessage.addListener(updateBg);
|
||||||
|
|
||||||
function updateBg(request, sender, sendResponse) {
|
function updateBg(request, sender, sendResponse) {
|
||||||
var html = document.querySelector('html');
|
let html = document.querySelector('html');
|
||||||
var body = document.querySelector('body');
|
let body = document.querySelector('body');
|
||||||
if (request.image) {
|
if (request.image) {
|
||||||
html.style.backgroundImage = 'url(' + request.image + ')';
|
html.style.backgroundImage = 'url(' + request.image + ')';
|
||||||
body.style.backgroundImage = 'url(' + request.image + ')';
|
body.style.backgroundImage = 'url(' + request.image + ')';
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
/* initialise variables */
|
/* initialise variables */
|
||||||
|
|
||||||
var bgBtns = document.querySelectorAll('.bg-container button');
|
let bgBtns = document.querySelectorAll('.bg-container button');
|
||||||
var colorPick = document.querySelector('input');
|
let colorPick = document.querySelector('input');
|
||||||
var reset = document.querySelector('.color-reset button');
|
let reset = document.querySelector('.color-reset button');
|
||||||
var cookieVal = { image : '',
|
let cookieVal = { image : '',
|
||||||
color : '' };
|
color : '' };
|
||||||
|
|
||||||
function getActiveTab() {
|
function getActiveTab() {
|
||||||
@@ -13,15 +13,15 @@ function getActiveTab() {
|
|||||||
/* apply backgrounds to buttons */
|
/* apply backgrounds to buttons */
|
||||||
/* add listener so that when clicked, button applies background to page HTML */
|
/* add listener so that when clicked, button applies background to page HTML */
|
||||||
|
|
||||||
for(var i = 0; i < bgBtns.length; i++) {
|
for(let i = 0; i < bgBtns.length; i++) {
|
||||||
var imgName = bgBtns[i].getAttribute('class');
|
let imgName = bgBtns[i].getAttribute('class');
|
||||||
var bgImg = 'url(\'images/' + imgName + '.png\')';
|
let bgImg = 'url(\'images/' + imgName + '.png\')';
|
||||||
bgBtns[i].style.backgroundImage = bgImg;
|
bgBtns[i].style.backgroundImage = bgImg;
|
||||||
|
|
||||||
bgBtns[i].onclick = function(e) {
|
bgBtns[i].onclick = function(e) {
|
||||||
getActiveTab().then((tabs) => {
|
getActiveTab().then((tabs) => {
|
||||||
var imgName = e.target.getAttribute('class');
|
let imgName = e.target.getAttribute('class');
|
||||||
var fullURL = browser.extension.getURL('popup/images/'+ imgName + '.png');
|
let fullURL = browser.extension.getURL('popup/images/'+ imgName + '.png');
|
||||||
browser.tabs.sendMessage(tabs[0].id, {image: fullURL});
|
browser.tabs.sendMessage(tabs[0].id, {image: fullURL});
|
||||||
|
|
||||||
cookieVal.image = fullURL;
|
cookieVal.image = fullURL;
|
||||||
@@ -38,7 +38,7 @@ for(var i = 0; i < bgBtns.length; i++) {
|
|||||||
|
|
||||||
colorPick.onchange = function(e) {
|
colorPick.onchange = function(e) {
|
||||||
getActiveTab().then((tabs) => {
|
getActiveTab().then((tabs) => {
|
||||||
var currColor = e.target.value;
|
let currColor = e.target.value;
|
||||||
browser.tabs.sendMessage(tabs[0].id, {color: currColor});
|
browser.tabs.sendMessage(tabs[0].id, {color: currColor});
|
||||||
|
|
||||||
cookieVal.color = currColor;
|
cookieVal.color = currColor;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var currentTheme = '';
|
let currentTheme = '';
|
||||||
|
|
||||||
const themes = {
|
const themes = {
|
||||||
'day': {
|
'day': {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
/* global getUsefulContents */
|
/* global getUsefulContents */
|
||||||
function start() {
|
function start() {
|
||||||
getUsefulContents(data => {
|
getUsefulContents(data => {
|
||||||
var display = document.getElementById('display');
|
let display = document.getElementById('display');
|
||||||
|
|
||||||
display.innerHTML = data;
|
display.innerHTML = data;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ exportFunction(notify, window, {defineAs:'notify'});
|
|||||||
* Because the object contains functions, the cloneInto call must include
|
* Because the object contains functions, the cloneInto call must include
|
||||||
* the `cloneFunctions` option.
|
* the `cloneFunctions` option.
|
||||||
*/
|
*/
|
||||||
var messenger = {
|
let messenger = {
|
||||||
notify: function(message) {
|
notify: function(message) {
|
||||||
browser.runtime.sendMessage({content: "Object method call: " + message});
|
browser.runtime.sendMessage({content: "Object method call: " + message});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ function saveOptions(e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function restoreOptions() {
|
function restoreOptions() {
|
||||||
var storageItem = browser.storage.managed.get('colour');
|
let storageItem = browser.storage.managed.get('colour');
|
||||||
storageItem.then((res) => {
|
storageItem.then((res) => {
|
||||||
document.querySelector("#managed-colour").innerText = res.colour;
|
document.querySelector("#managed-colour").innerText = res.colour;
|
||||||
});
|
});
|
||||||
|
|
||||||
var gettingItem = browser.storage.sync.get('colour');
|
let gettingItem = browser.storage.sync.get('colour');
|
||||||
gettingItem.then((res) => {
|
gettingItem.then((res) => {
|
||||||
document.querySelector("#colour").value = res.colour || 'Firefox red';
|
document.querySelector("#colour").value = res.colour || 'Firefox red';
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
Default settings. If there is nothing in storage, use these values.
|
Default settings. If there is nothing in storage, use these values.
|
||||||
*/
|
*/
|
||||||
var defaultSettings = {
|
let defaultSettings = {
|
||||||
since: "hour",
|
since: "hour",
|
||||||
dataTypes: ["history", "downloads"]
|
dataTypes: ["history", "downloads"]
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// A useful way to extract the domain from a url.
|
// A useful way to extract the domain from a url.
|
||||||
function get_hostname(url) {
|
function get_hostname(url) {
|
||||||
var a = document.createElement('a');
|
let a = document.createElement('a');
|
||||||
a.href = url;
|
a.href = url;
|
||||||
set_domain(a.hostname);
|
set_domain(a.hostname);
|
||||||
return a.hostname;
|
return a.hostname;
|
||||||
@@ -14,7 +14,7 @@ function set_domain(domain) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function no_history(hostname) {
|
function no_history(hostname) {
|
||||||
var history_text = document.getElementById('history');
|
let history_text = document.getElementById('history');
|
||||||
while(history_text.firstChild)
|
while(history_text.firstChild)
|
||||||
history_text.removeChild(history_text.firstChild);
|
history_text.removeChild(history_text.firstChild);
|
||||||
history_text.textContent = `No history for ${hostname}.`;
|
history_text.textContent = `No history for ${hostname}.`;
|
||||||
@@ -27,22 +27,22 @@ function getActiveTab() {
|
|||||||
// When the page is loaded find the current tab and then use that to query
|
// When the page is loaded find the current tab and then use that to query
|
||||||
// the history.
|
// the history.
|
||||||
getActiveTab().then((tabs) => {
|
getActiveTab().then((tabs) => {
|
||||||
var list = document.getElementById('history');
|
let list = document.getElementById('history');
|
||||||
var hostname = get_hostname(tabs[0].url);
|
let hostname = get_hostname(tabs[0].url);
|
||||||
|
|
||||||
// Search for all history entries for the current windows domain.
|
// Search for all history entries for the current windows domain.
|
||||||
// Because this could be a lot of entries, lets limit it to 5.
|
// Because this could be a lot of entries, lets limit it to 5.
|
||||||
var searchingHistory = browser.history.search({text: hostname, maxResults: 5});
|
let searchingHistory = browser.history.search({text: hostname, maxResults: 5});
|
||||||
searchingHistory.then((results) => {
|
searchingHistory.then((results) => {
|
||||||
// What to show if there are no results.
|
// What to show if there are no results.
|
||||||
if (results.length < 1) {
|
if (results.length < 1) {
|
||||||
no_history(hostname);
|
no_history(hostname);
|
||||||
} else {
|
} else {
|
||||||
for (var k in results) {
|
for (let k in results) {
|
||||||
var history = results[k];
|
let history = results[k];
|
||||||
var li = document.createElement('p');
|
let li = document.createElement('p');
|
||||||
var a = document.createElement('a');
|
let a = document.createElement('a');
|
||||||
var url = document.createTextNode(history.url);
|
let url = document.createTextNode(history.url);
|
||||||
a.href = history.url;
|
a.href = history.url;
|
||||||
a.target = '_blank';
|
a.target = '_blank';
|
||||||
a.appendChild(url);
|
a.appendChild(url);
|
||||||
@@ -55,7 +55,7 @@ getActiveTab().then((tabs) => {
|
|||||||
|
|
||||||
function clearAll(e) {
|
function clearAll(e) {
|
||||||
getActiveTab().then((tabs) => {
|
getActiveTab().then((tabs) => {
|
||||||
var hostname = get_hostname(tabs[0].url);
|
let hostname = get_hostname(tabs[0].url);
|
||||||
if (!hostname) {
|
if (!hostname) {
|
||||||
// Don't try and delete history when there's no hostname.
|
// Don't try and delete history when there's no hostname.
|
||||||
return;
|
return;
|
||||||
@@ -63,7 +63,7 @@ function clearAll(e) {
|
|||||||
|
|
||||||
// Search will return us a list of histories for this domain.
|
// Search will return us a list of histories for this domain.
|
||||||
// Loop through them and delete them one by one.
|
// Loop through them and delete them one by one.
|
||||||
var searchingHistory = browser.history.search({text: hostname})
|
let searchingHistory = browser.history.search({text: hostname})
|
||||||
searchingHistory.then((results) => {
|
searchingHistory.then((results) => {
|
||||||
for (let k in results) {
|
for (let k in results) {
|
||||||
browser.history.deleteUrl({url: results[k].url});
|
browser.history.deleteUrl({url: results[k].url});
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
|
|
||||||
var latestDownloadId;
|
let latestDownloadId;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Callback from getFileIcon.
|
Callback from getFileIcon.
|
||||||
Initialize the displayed icon.
|
Initialize the displayed icon.
|
||||||
*/
|
*/
|
||||||
function updateIconUrl(iconUrl) {
|
function updateIconUrl(iconUrl) {
|
||||||
var downloadIcon = document.querySelector("#icon");
|
let downloadIcon = document.querySelector("#icon");
|
||||||
downloadIcon.setAttribute("src", iconUrl);
|
downloadIcon.setAttribute("src", iconUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,10 +22,10 @@ If there was a download item,
|
|||||||
If there wasn't a download item, disable the "open" and "remove" buttons.
|
If there wasn't a download item, disable the "open" and "remove" buttons.
|
||||||
*/
|
*/
|
||||||
function initializeLatestDownload(downloadItems) {
|
function initializeLatestDownload(downloadItems) {
|
||||||
var downloadUrl = document.querySelector("#url");
|
let downloadUrl = document.querySelector("#url");
|
||||||
if (downloadItems.length > 0) {
|
if (downloadItems.length > 0) {
|
||||||
latestDownloadId = downloadItems[0].id;
|
latestDownloadId = downloadItems[0].id;
|
||||||
var gettingIconUrl = browser.downloads.getFileIcon(latestDownloadId);
|
let gettingIconUrl = browser.downloads.getFileIcon(latestDownloadId);
|
||||||
gettingIconUrl.then(updateIconUrl, onError);
|
gettingIconUrl.then(updateIconUrl, onError);
|
||||||
downloadUrl.textContent = downloadItems[0].url;
|
downloadUrl.textContent = downloadItems[0].url;
|
||||||
document.querySelector("#open").classList.remove("disabled");
|
document.querySelector("#open").classList.remove("disabled");
|
||||||
@@ -40,7 +40,7 @@ function initializeLatestDownload(downloadItems) {
|
|||||||
/*
|
/*
|
||||||
Search for the most recent download, and pass it to initializeLatestDownload()
|
Search for the most recent download, and pass it to initializeLatestDownload()
|
||||||
*/
|
*/
|
||||||
var searching = browser.downloads.search({
|
let searching = browser.downloads.search({
|
||||||
limit: 1,
|
limit: 1,
|
||||||
orderBy: ["-startTime"]
|
orderBy: ["-startTime"]
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ function showCookiesForTab(tabs) {
|
|||||||
let tab = tabs.pop();
|
let tab = tabs.pop();
|
||||||
|
|
||||||
//get all cookies in the domain
|
//get all cookies in the domain
|
||||||
var gettingAllCookies = browser.cookies.getAll({url: tab.url});
|
let gettingAllCookies = browser.cookies.getAll({url: tab.url});
|
||||||
gettingAllCookies.then((cookies) => {
|
gettingAllCookies.then((cookies) => {
|
||||||
|
|
||||||
//set the header of the panel
|
//set the header of the panel
|
||||||
var activeTabUrl = document.getElementById('header-title');
|
let activeTabUrl = document.getElementById('header-title');
|
||||||
var text = document.createTextNode("Cookies at: "+tab.title);
|
let text = document.createTextNode("Cookies at: "+tab.title);
|
||||||
var cookieList = document.getElementById('cookie-list');
|
let cookieList = document.getElementById('cookie-list');
|
||||||
activeTabUrl.appendChild(text);
|
activeTabUrl.appendChild(text);
|
||||||
|
|
||||||
if (cookies.length > 0) {
|
if (cookies.length > 0) {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ function detectAccessKeyMenuFeature() {
|
|||||||
// on parameter properties.
|
// on parameter properties.
|
||||||
}
|
}
|
||||||
|
|
||||||
var IS_ACCESS_KEY_SUPPORTED = detectAccessKeyMenuFeature();
|
let IS_ACCESS_KEY_SUPPORTED = detectAccessKeyMenuFeature();
|
||||||
|
|
||||||
function formatMenuLabel(menuLabel) {
|
function formatMenuLabel(menuLabel) {
|
||||||
if (!IS_ACCESS_KEY_SUPPORTED) {
|
if (!IS_ACCESS_KEY_SUPPORTED) {
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ browser.menus.create({
|
|||||||
contexts: ["all"]
|
contexts: ["all"]
|
||||||
}, onCreated);
|
}, onCreated);
|
||||||
|
|
||||||
var checkedState = true;
|
let checkedState = true;
|
||||||
|
|
||||||
browser.menus.create({
|
browser.menus.create({
|
||||||
id: "check-uncheck",
|
id: "check-uncheck",
|
||||||
@@ -106,8 +106,8 @@ Set a colored border on the document in the given tab.
|
|||||||
Note that this only work on normal web pages, not special pages
|
Note that this only work on normal web pages, not special pages
|
||||||
like about:debugging.
|
like about:debugging.
|
||||||
*/
|
*/
|
||||||
var blue = 'document.body.style.border = "5px solid blue"';
|
let blue = 'document.body.style.border = "5px solid blue"';
|
||||||
var green = 'document.body.style.border = "5px solid green"';
|
let green = 'document.body.style.border = "5px solid green"';
|
||||||
|
|
||||||
function borderify(tabId, color) {
|
function borderify(tabId, color) {
|
||||||
browser.tabs.executeScript(tabId, {
|
browser.tabs.executeScript(tabId, {
|
||||||
@@ -146,7 +146,7 @@ browser.menus.onClicked.addListener((info, tab) => {
|
|||||||
console.log(info.selectionText);
|
console.log(info.selectionText);
|
||||||
break;
|
break;
|
||||||
case "remove-me":
|
case "remove-me":
|
||||||
var removing = browser.menus.remove(info.menuItemId);
|
let removing = browser.menus.remove(info.menuItemId);
|
||||||
removing.then(onRemoved, onError);
|
removing.then(onRemoved, onError);
|
||||||
break;
|
break;
|
||||||
case "bluify":
|
case "bluify":
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var popupParameters;
|
let popupParameters;
|
||||||
|
|
||||||
browser.menus.create({
|
browser.menus.create({
|
||||||
id: "remove_element",
|
id: "remove_element",
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var highlightedBox;
|
let highlightedBox;
|
||||||
function highlightElement(element) {
|
function highlightElement(element) {
|
||||||
removeHighlights();
|
removeHighlights();
|
||||||
let boundingRect = element.getBoundingClientRect();
|
let boundingRect = element.getBoundingClientRect();
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
// if the given first parameter matches the info.targetElementId integer from
|
// if the given first parameter matches the info.targetElementId integer from
|
||||||
// the menus.onClicked or menus.onShown events.
|
// the menus.onClicked or menus.onShown events.
|
||||||
if (!browser.menus || !browser.menus.getTargetElement) {
|
if (!browser.menus || !browser.menus.getTargetElement) {
|
||||||
var menuTarget = null;
|
let menuTarget = null;
|
||||||
let cleanupIfNeeded = () => {
|
let cleanupIfNeeded = () => {
|
||||||
if (menuTarget && !document.contains(menuTarget)) menuTarget = null;
|
if (menuTarget && !document.contains(menuTarget)) menuTarget = null;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var Background = {
|
let Background = {
|
||||||
receiveMessage: function(msg, sender, sendResponse) {
|
receiveMessage: function(msg, sender, sendResponse) {
|
||||||
if (msg && msg.action && Background.hasOwnProperty(msg.action)) {
|
if (msg && msg.action && Background.hasOwnProperty(msg.action)) {
|
||||||
return Background[msg.action](msg, sender, sendResponse);
|
return Background[msg.action](msg, sender, sendResponse);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
setInterval(function() {
|
setInterval(function() {
|
||||||
var $game = document.querySelector('#game');
|
let $game = document.querySelector('#game');
|
||||||
if($game.innerText !== 'ping'){
|
if($game.innerText !== 'ping'){
|
||||||
$game.innerText = 'ping';
|
$game.innerText = 'ping';
|
||||||
} else{
|
} else{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
On startup, connect to the "ping_pong" app.
|
On startup, connect to the "ping_pong" app.
|
||||||
*/
|
*/
|
||||||
var port = browser.runtime.connectNative("ping_pong");
|
let port = browser.runtime.connectNative("ping_pong");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Listen for messages from the app.
|
Listen for messages from the app.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Load existent stats with the storage API.
|
// Load existent stats with the storage API.
|
||||||
var gettingStoredStats = browser.storage.local.get();
|
let gettingStoredStats = browser.storage.local.get();
|
||||||
|
|
||||||
gettingStoredStats.then(results => {
|
gettingStoredStats.then(results => {
|
||||||
// Initialize the saved stats if not yet initialized.
|
// Initialize the saved stats if not yet initialized.
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ function addElements(element, array, callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var gettingStoredStats = browser.storage.local.get();
|
let gettingStoredStats = browser.storage.local.get();
|
||||||
gettingStoredStats.then(results => {
|
gettingStoredStats.then(results => {
|
||||||
if (results.type.length === 0 || results.host.length === 0) {
|
if (results.type.length === 0 || results.host.length === 0) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ which we read from the message.
|
|||||||
*/
|
*/
|
||||||
function notify(message) {
|
function notify(message) {
|
||||||
console.log("background script received message");
|
console.log("background script received message");
|
||||||
var title = browser.i18n.getMessage("notificationTitle");
|
let title = browser.i18n.getMessage("notificationTitle");
|
||||||
var content = browser.i18n.getMessage("notificationContent", message.url);
|
let content = browser.i18n.getMessage("notificationContent", message.url);
|
||||||
browser.notifications.create({
|
browser.notifications.create({
|
||||||
"type": "basic",
|
"type": "basic",
|
||||||
"iconUrl": browser.extension.getURL("icons/link-48.png"),
|
"iconUrl": browser.extension.getURL("icons/link-48.png"),
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ If the click was on a link, send a message to the background page.
|
|||||||
The message contains the link's URL.
|
The message contains the link's URL.
|
||||||
*/
|
*/
|
||||||
function notifyExtension(e) {
|
function notifyExtension(e) {
|
||||||
var target = e.target;
|
let target = e.target;
|
||||||
while ((target.tagName != "A" || !target.href) && target.parentNode) {
|
while ((target.tagName != "A" || !target.href) && target.parentNode) {
|
||||||
target = target.parentNode;
|
target = target.parentNode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,5 +24,5 @@ function messagePageScript() {
|
|||||||
Add messagePageScript() as a listener to click events on
|
Add messagePageScript() as a listener to click events on
|
||||||
the "from-content-script" element.
|
the "from-content-script" element.
|
||||||
*/
|
*/
|
||||||
var fromContentScript = document.getElementById("from-content-script");
|
let fromContentScript = document.getElementById("from-content-script");
|
||||||
fromContentScript.addEventListener("click", messagePageScript);
|
fromContentScript.addEventListener("click", messagePageScript);
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
/* initialise variables */
|
/* initialise variables */
|
||||||
|
|
||||||
var inputTitle = document.querySelector('.new-note input');
|
let inputTitle = document.querySelector('.new-note input');
|
||||||
var inputBody = document.querySelector('.new-note textarea');
|
let inputBody = document.querySelector('.new-note textarea');
|
||||||
|
|
||||||
var noteContainer = document.querySelector('.note-container');
|
let noteContainer = document.querySelector('.note-container');
|
||||||
|
|
||||||
|
|
||||||
var clearBtn = document.querySelector('.clear');
|
let clearBtn = document.querySelector('.clear');
|
||||||
var addBtn = document.querySelector('.add');
|
let addBtn = document.querySelector('.add');
|
||||||
|
|
||||||
/* add event listeners to buttons */
|
/* add event listeners to buttons */
|
||||||
|
|
||||||
@@ -24,11 +24,11 @@ function onError(error) {
|
|||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
function initialize() {
|
function initialize() {
|
||||||
var gettingAllStorageItems = browser.storage.local.get(null);
|
let gettingAllStorageItems = browser.storage.local.get(null);
|
||||||
gettingAllStorageItems.then((results) => {
|
gettingAllStorageItems.then((results) => {
|
||||||
var noteKeys = Object.keys(results);
|
let noteKeys = Object.keys(results);
|
||||||
for (let noteKey of noteKeys) {
|
for (let noteKey of noteKeys) {
|
||||||
var curValue = results[noteKey];
|
let curValue = results[noteKey];
|
||||||
displayNote(noteKey,curValue);
|
displayNote(noteKey,curValue);
|
||||||
}
|
}
|
||||||
}, onError);
|
}, onError);
|
||||||
@@ -37,11 +37,11 @@ function initialize() {
|
|||||||
/* Add a note to the display, and storage */
|
/* Add a note to the display, and storage */
|
||||||
|
|
||||||
function addNote() {
|
function addNote() {
|
||||||
var noteTitle = inputTitle.value;
|
let noteTitle = inputTitle.value;
|
||||||
var noteBody = inputBody.value;
|
let noteBody = inputBody.value;
|
||||||
var gettingItem = browser.storage.local.get(noteTitle);
|
let gettingItem = browser.storage.local.get(noteTitle);
|
||||||
gettingItem.then((result) => {
|
gettingItem.then((result) => {
|
||||||
var objTest = Object.keys(result);
|
let objTest = Object.keys(result);
|
||||||
if(objTest.length < 1 && noteTitle !== '' && noteBody !== '') {
|
if(objTest.length < 1 && noteTitle !== '' && noteBody !== '') {
|
||||||
inputTitle.value = '';
|
inputTitle.value = '';
|
||||||
inputBody.value = '';
|
inputBody.value = '';
|
||||||
@@ -53,7 +53,7 @@ function addNote() {
|
|||||||
/* function to store a new note in storage */
|
/* function to store a new note in storage */
|
||||||
|
|
||||||
function storeNote(title, body) {
|
function storeNote(title, body) {
|
||||||
var storingNote = browser.storage.local.set({ [title] : body });
|
let storingNote = browser.storage.local.set({ [title] : body });
|
||||||
storingNote.then(() => {
|
storingNote.then(() => {
|
||||||
displayNote(title,body);
|
displayNote(title,body);
|
||||||
}, onError);
|
}, onError);
|
||||||
@@ -64,12 +64,12 @@ function storeNote(title, body) {
|
|||||||
function displayNote(title, body) {
|
function displayNote(title, body) {
|
||||||
|
|
||||||
/* create note display box */
|
/* create note display box */
|
||||||
var note = document.createElement('div');
|
let note = document.createElement('div');
|
||||||
var noteDisplay = document.createElement('div');
|
let noteDisplay = document.createElement('div');
|
||||||
var noteH = document.createElement('h2');
|
let noteH = document.createElement('h2');
|
||||||
var notePara = document.createElement('p');
|
let notePara = document.createElement('p');
|
||||||
var deleteBtn = document.createElement('button');
|
let deleteBtn = document.createElement('button');
|
||||||
var clearFix = document.createElement('div');
|
let clearFix = document.createElement('div');
|
||||||
|
|
||||||
note.setAttribute('class','note');
|
note.setAttribute('class','note');
|
||||||
|
|
||||||
@@ -95,13 +95,13 @@ function displayNote(title, body) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
/* create note edit box */
|
/* create note edit box */
|
||||||
var noteEdit = document.createElement('div');
|
let noteEdit = document.createElement('div');
|
||||||
var noteTitleEdit = document.createElement('input');
|
let noteTitleEdit = document.createElement('input');
|
||||||
var noteBodyEdit = document.createElement('textarea');
|
let noteBodyEdit = document.createElement('textarea');
|
||||||
var clearFix2 = document.createElement('div');
|
let clearFix2 = document.createElement('div');
|
||||||
|
|
||||||
var updateBtn = document.createElement('button');
|
let updateBtn = document.createElement('button');
|
||||||
var cancelBtn = document.createElement('button');
|
let cancelBtn = document.createElement('button');
|
||||||
|
|
||||||
updateBtn.setAttribute('class','update');
|
updateBtn.setAttribute('class','update');
|
||||||
updateBtn.textContent = 'Update note';
|
updateBtn.textContent = 'Update note';
|
||||||
@@ -154,10 +154,10 @@ function displayNote(title, body) {
|
|||||||
/* function to update notes */
|
/* function to update notes */
|
||||||
|
|
||||||
function updateNote(delNote,newTitle,newBody) {
|
function updateNote(delNote,newTitle,newBody) {
|
||||||
var storingNote = browser.storage.local.set({ [newTitle] : newBody });
|
let storingNote = browser.storage.local.set({ [newTitle] : newBody });
|
||||||
storingNote.then(() => {
|
storingNote.then(() => {
|
||||||
if(delNote !== newTitle) {
|
if(delNote !== newTitle) {
|
||||||
var removingNote = browser.storage.local.remove(delNote);
|
let removingNote = browser.storage.local.remove(delNote);
|
||||||
removingNote.then(() => {
|
removingNote.then(() => {
|
||||||
displayNote(newTitle, newBody);
|
displayNote(newTitle, newBody);
|
||||||
}, onError);
|
}, onError);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var rootCertStats = {};
|
let rootCertStats = {};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
On an onHeadersReceived event, if there was a successful TLS connection
|
On an onHeadersReceived event, if there was a successful TLS connection
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
copy the selected text to clipboard
|
copy the selected text to clipboard
|
||||||
*/
|
*/
|
||||||
function copySelection() {
|
function copySelection() {
|
||||||
var selectedText = window.getSelection().toString().trim();
|
let selectedText = window.getSelection().toString().trim();
|
||||||
|
|
||||||
if (selectedText) {
|
if (selectedText) {
|
||||||
document.execCommand("Copy");
|
document.execCommand("Copy");
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
|
|
||||||
var target = "https://httpbin.org/basic-auth/*";
|
let target = "https://httpbin.org/basic-auth/*";
|
||||||
|
|
||||||
var pendingRequests = [];
|
let pendingRequests = [];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
A request has completed. We can stop worrying about it.
|
A request has completed. We can stop worrying about it.
|
||||||
*/
|
*/
|
||||||
function completed(requestDetails) {
|
function completed(requestDetails) {
|
||||||
console.log("completed: " + requestDetails.requestId);
|
console.log("completed: " + requestDetails.requestId);
|
||||||
var index = pendingRequests.indexOf(requestDetails.requestId);
|
let index = pendingRequests.indexOf(requestDetails.requestId);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
pendingRequests.splice(index, 1);
|
pendingRequests.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
Default settings. Initialize storage to these values.
|
Default settings. Initialize storage to these values.
|
||||||
*/
|
*/
|
||||||
var authCredentials = {
|
let authCredentials = {
|
||||||
username: "user",
|
username: "user",
|
||||||
password: "passwd"
|
password: "passwd"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const MIN_ZOOM = 0.3;
|
|||||||
const DEFAULT_ZOOM = 1;
|
const DEFAULT_ZOOM = 1;
|
||||||
|
|
||||||
function firstUnpinnedTab(tabs) {
|
function firstUnpinnedTab(tabs) {
|
||||||
for (var tab of tabs) {
|
for (let tab of tabs) {
|
||||||
if (!tab.pinned) {
|
if (!tab.pinned) {
|
||||||
return tab.index;
|
return tab.index;
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ function getCurrentWindowTabs() {
|
|||||||
document.addEventListener("click", (e) => {
|
document.addEventListener("click", (e) => {
|
||||||
function callOnActiveTab(callback) {
|
function callOnActiveTab(callback) {
|
||||||
getCurrentWindowTabs().then((tabs) => {
|
getCurrentWindowTabs().then((tabs) => {
|
||||||
for (var tab of tabs) {
|
for (let tab of tabs) {
|
||||||
if (tab.active) {
|
if (tab.active) {
|
||||||
callback(tab, tabs);
|
callback(tab, tabs);
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ document.addEventListener("click", (e) => {
|
|||||||
|
|
||||||
if (e.target.id === "tabs-move-beginning") {
|
if (e.target.id === "tabs-move-beginning") {
|
||||||
callOnActiveTab((tab, tabs) => {
|
callOnActiveTab((tab, tabs) => {
|
||||||
var index = 0;
|
let index = 0;
|
||||||
if (!tab.pinned) {
|
if (!tab.pinned) {
|
||||||
index = firstUnpinnedTab(tabs);
|
index = firstUnpinnedTab(tabs);
|
||||||
}
|
}
|
||||||
@@ -71,9 +71,9 @@ document.addEventListener("click", (e) => {
|
|||||||
|
|
||||||
if (e.target.id === "tabs-move-end") {
|
if (e.target.id === "tabs-move-end") {
|
||||||
callOnActiveTab((tab, tabs) => {
|
callOnActiveTab((tab, tabs) => {
|
||||||
var index = -1;
|
let index = -1;
|
||||||
if (tab.pinned) {
|
if (tab.pinned) {
|
||||||
var lastPinnedTab = Math.max(0, firstUnpinnedTab(tabs) - 1);
|
let lastPinnedTab = Math.max(0, firstUnpinnedTab(tabs) - 1);
|
||||||
index = lastPinnedTab;
|
index = lastPinnedTab;
|
||||||
}
|
}
|
||||||
browser.tabs.move([tab.id], {index});
|
browser.tabs.move([tab.id], {index});
|
||||||
@@ -118,13 +118,13 @@ document.addEventListener("click", (e) => {
|
|||||||
|
|
||||||
else if (e.target.id === "tabs-add-zoom") {
|
else if (e.target.id === "tabs-add-zoom") {
|
||||||
callOnActiveTab((tab) => {
|
callOnActiveTab((tab) => {
|
||||||
var gettingZoom = browser.tabs.getZoom(tab.id);
|
let gettingZoom = browser.tabs.getZoom(tab.id);
|
||||||
gettingZoom.then((zoomFactor) => {
|
gettingZoom.then((zoomFactor) => {
|
||||||
//the maximum zoomFactor is 5, it can't go higher
|
//the maximum zoomFactor is 5, it can't go higher
|
||||||
if (zoomFactor >= MAX_ZOOM) {
|
if (zoomFactor >= MAX_ZOOM) {
|
||||||
alert("Tab zoom factor is already at max!");
|
alert("Tab zoom factor is already at max!");
|
||||||
} else {
|
} else {
|
||||||
var newZoomFactor = zoomFactor + ZOOM_INCREMENT;
|
let newZoomFactor = zoomFactor + ZOOM_INCREMENT;
|
||||||
//if the newZoomFactor is set to higher than the max accepted
|
//if the newZoomFactor is set to higher than the max accepted
|
||||||
//it won't change, and will never alert that it's at maximum
|
//it won't change, and will never alert that it's at maximum
|
||||||
newZoomFactor = newZoomFactor > MAX_ZOOM ? MAX_ZOOM : newZoomFactor;
|
newZoomFactor = newZoomFactor > MAX_ZOOM ? MAX_ZOOM : newZoomFactor;
|
||||||
@@ -136,13 +136,13 @@ document.addEventListener("click", (e) => {
|
|||||||
|
|
||||||
else if (e.target.id === "tabs-decrease-zoom") {
|
else if (e.target.id === "tabs-decrease-zoom") {
|
||||||
callOnActiveTab((tab) => {
|
callOnActiveTab((tab) => {
|
||||||
var gettingZoom = browser.tabs.getZoom(tab.id);
|
let gettingZoom = browser.tabs.getZoom(tab.id);
|
||||||
gettingZoom.then((zoomFactor) => {
|
gettingZoom.then((zoomFactor) => {
|
||||||
//the minimum zoomFactor is 0.3, it can't go lower
|
//the minimum zoomFactor is 0.3, it can't go lower
|
||||||
if (zoomFactor <= MIN_ZOOM) {
|
if (zoomFactor <= MIN_ZOOM) {
|
||||||
alert("Tab zoom factor is already at minimum!");
|
alert("Tab zoom factor is already at minimum!");
|
||||||
} else {
|
} else {
|
||||||
var newZoomFactor = zoomFactor - ZOOM_INCREMENT;
|
let newZoomFactor = zoomFactor - ZOOM_INCREMENT;
|
||||||
//if the newZoomFactor is set to lower than the min accepted
|
//if the newZoomFactor is set to lower than the min accepted
|
||||||
//it won't change, and will never alert that it's at minimum
|
//it won't change, and will never alert that it's at minimum
|
||||||
newZoomFactor = newZoomFactor < MIN_ZOOM ? MIN_ZOOM : newZoomFactor;
|
newZoomFactor = newZoomFactor < MIN_ZOOM ? MIN_ZOOM : newZoomFactor;
|
||||||
@@ -154,7 +154,7 @@ document.addEventListener("click", (e) => {
|
|||||||
|
|
||||||
else if (e.target.id === "tabs-default-zoom") {
|
else if (e.target.id === "tabs-default-zoom") {
|
||||||
callOnActiveTab((tab) => {
|
callOnActiveTab((tab) => {
|
||||||
var gettingZoom = browser.tabs.getZoom(tab.id);
|
let gettingZoom = browser.tabs.getZoom(tab.id);
|
||||||
gettingZoom.then((zoomFactor) => {
|
gettingZoom.then((zoomFactor) => {
|
||||||
if (zoomFactor == DEFAULT_ZOOM) {
|
if (zoomFactor == DEFAULT_ZOOM) {
|
||||||
alert("Tab zoom is already at the default zoom factor");
|
alert("Tab zoom is already at the default zoom factor");
|
||||||
@@ -166,12 +166,12 @@ document.addEventListener("click", (e) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (e.target.classList.contains('switch-tabs')) {
|
else if (e.target.classList.contains('switch-tabs')) {
|
||||||
var tabId = +e.target.getAttribute('href');
|
let tabId = +e.target.getAttribute('href');
|
||||||
|
|
||||||
browser.tabs.query({
|
browser.tabs.query({
|
||||||
currentWindow: true
|
currentWindow: true
|
||||||
}).then((tabs) => {
|
}).then((tabs) => {
|
||||||
for (var tab of tabs) {
|
for (let tab of tabs) {
|
||||||
if (tab.id === tabId) {
|
if (tab.id === tabId) {
|
||||||
browser.tabs.update(tabId, {
|
browser.tabs.update(tabId, {
|
||||||
active: true
|
active: true
|
||||||
@@ -197,7 +197,7 @@ browser.tabs.onRemoved.addListener((tabId, removeInfo) => {
|
|||||||
|
|
||||||
//onMoved listener. fired when tab is moved into the same window
|
//onMoved listener. fired when tab is moved into the same window
|
||||||
browser.tabs.onMoved.addListener((tabId, moveInfo) => {
|
browser.tabs.onMoved.addListener((tabId, moveInfo) => {
|
||||||
var startIndex = moveInfo.fromIndex;
|
let startIndex = moveInfo.fromIndex;
|
||||||
var endIndex = moveInfo.toIndex;
|
let endIndex = moveInfo.toIndex;
|
||||||
console.log(`Tab with id: ${tabId} moved from index: ${startIndex} to index: ${endIndex}`);
|
console.log(`Tab with id: ${tabId} moved from index: ${startIndex} to index: ${endIndex}`);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var themeList = document.getElementById('theme-list');
|
let themeList = document.getElementById('theme-list');
|
||||||
|
|
||||||
function enableTheme(e) {
|
function enableTheme(e) {
|
||||||
browser.management.setEnabled(e.target.value, true);
|
browser.management.setEnabled(e.target.value, true);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
browser.topSites.get()
|
browser.topSites.get()
|
||||||
.then((sites) => {
|
.then((sites) => {
|
||||||
var div = document.getElementById('site-list');
|
let div = document.getElementById('site-list');
|
||||||
|
|
||||||
if (!sites.length) {
|
if (!sites.length) {
|
||||||
div.innerText = 'No sites returned from the topSites API.';
|
div.innerText = 'No sites returned from the topSites API.';
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
/*
|
/*
|
||||||
This is the page for which we want to rewrite the User-Agent header.
|
This is the page for which we want to rewrite the User-Agent header.
|
||||||
*/
|
*/
|
||||||
var targetPage = "https://httpbin.org/*";
|
let targetPage = "https://httpbin.org/*";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Map browser names to UA strings.
|
Map browser names to UA strings.
|
||||||
*/
|
*/
|
||||||
var uaStrings = {
|
let uaStrings = {
|
||||||
"Firefox 41": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:41.0) Gecko/20100101 Firefox/41.0",
|
"Firefox 41": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:41.0) Gecko/20100101 Firefox/41.0",
|
||||||
"Chrome 41": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36",
|
"Chrome 41": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36",
|
||||||
"IE 11": "Mozilla/5.0 (compatible, MSIE 11, Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko"
|
"IE 11": "Mozilla/5.0 (compatible, MSIE 11, Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko"
|
||||||
@@ -17,13 +17,13 @@ var uaStrings = {
|
|||||||
/*
|
/*
|
||||||
Initialize the UA to Firefox 41.
|
Initialize the UA to Firefox 41.
|
||||||
*/
|
*/
|
||||||
var ua = uaStrings["Firefox 41"];
|
let ua = uaStrings["Firefox 41"];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Rewrite the User-Agent header to "ua".
|
Rewrite the User-Agent header to "ua".
|
||||||
*/
|
*/
|
||||||
function rewriteUserAgentHeader(e) {
|
function rewriteUserAgentHeader(e) {
|
||||||
for (var header of e.requestHeaders) {
|
for (let header of e.requestHeaders) {
|
||||||
if (header.name.toLowerCase() === "user-agent") {
|
if (header.name.toLowerCase() === "user-agent") {
|
||||||
header.value = ua;
|
header.value = ua;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ document.addEventListener("click", (e) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var chosenUa = e.target.textContent;
|
let chosenUa = e.target.textContent;
|
||||||
var backgroundPage = browser.extension.getBackgroundPage();
|
let backgroundPage = browser.extension.getBackgroundPage();
|
||||||
backgroundPage.setUaString(chosenUa);
|
backgroundPage.setUaString(chosenUa);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ document.getElementById("leftpad-form").addEventListener("submit", (e) => {
|
|||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
document.getElementById("pad-bg").addEventListener("click", (e) => {
|
document.getElementById("pad-bg").addEventListener("click", (e) => {
|
||||||
var sendingMessage = browser.runtime.sendMessage({
|
let sendingMessage = browser.runtime.sendMessage({
|
||||||
text: textNode.value,
|
text: textNode.value,
|
||||||
amount: amountNode.valueAsNumber,
|
amount: amountNode.valueAsNumber,
|
||||||
with: withNode.value
|
with: withNode.value
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ document.addEventListener("click", (e) => {
|
|||||||
|
|
||||||
if (e.target.id === "window-update-size_768") {
|
if (e.target.id === "window-update-size_768") {
|
||||||
getCurrentWindow().then((currentWindow) => {
|
getCurrentWindow().then((currentWindow) => {
|
||||||
var updateInfo = {
|
let updateInfo = {
|
||||||
width: 768,
|
width: 768,
|
||||||
height: 1024
|
height: 1024
|
||||||
};
|
};
|
||||||
@@ -17,7 +17,7 @@ document.addEventListener("click", (e) => {
|
|||||||
|
|
||||||
if (e.target.id === "window-update-minimize") {
|
if (e.target.id === "window-update-minimize") {
|
||||||
getCurrentWindow().then((currentWindow) => {
|
getCurrentWindow().then((currentWindow) => {
|
||||||
var updateInfo = {
|
let updateInfo = {
|
||||||
state: "minimized"
|
state: "minimized"
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -80,13 +80,13 @@ document.addEventListener("click", (e) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (e.target.id === "window-resize-all") {
|
else if (e.target.id === "window-resize-all") {
|
||||||
var gettingAll = browser.windows.getAll();
|
let gettingAll = browser.windows.getAll();
|
||||||
gettingAll.then((windows) => {
|
gettingAll.then((windows) => {
|
||||||
var updateInfo = {
|
let updateInfo = {
|
||||||
width: 1024,
|
width: 1024,
|
||||||
height: 768
|
height: 768
|
||||||
};
|
};
|
||||||
for (var item of windows) {
|
for (let item of windows) {
|
||||||
browser.windows.update(item.id, updateInfo);
|
browser.windows.update(item.id, updateInfo);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user