Skip to content

Commit

Permalink
eslint formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cgorringe committed Aug 13, 2024
1 parent bd8ea86 commit 7898148
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 24 deletions.
6 changes: 4 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "standard",
"env": {
"browser": true,
"webextensions": true
"webextensions": true,
"worker": true
},
"rules": {
"indent": ["warn", 2, { "SwitchCase": 1, "MemberExpression": "off" }],
Expand All @@ -13,7 +14,8 @@
"quote-props": "off",
"one-var": "off",
"padded-blocks": "off",
"dot-notation": "off"
"dot-notation": "off",
"semi": "off"
},
"globals": {
"$": "readonly"
Expand Down
4 changes: 2 additions & 2 deletions webextension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"scripting",
"webRequest"
],
"host_permissions":[
"host_permissions": [
"https://archive.org/*",
"https://*.archive.org/*",
"https://hypothes.is/*",
Expand All @@ -54,7 +54,7 @@
}
],
"web_accessible_resources": [{
"resources":[ "/css/archive.css","/images/*"],
"resources": ["/css/archive.css", "/images/*"],
"matches": ["<all_urls>"]
}]
}
19 changes: 5 additions & 14 deletions webextension/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (typeof importScripts === 'function') {
// from 'utils.js'
/* global isNotExcludedUrl, getCleanUrl, isArchiveUrl, isValidUrl, notifyMsg, openByWindowSetting, sleep, wmAvailabilityCheck, hostURL */
/* global initDefaultOptions, badgeCountText, getWaybackCount, newshosts, dateToTimestamp, fixedEncodeURIComponent, checkLastError */
/* global hostHeaders, gCustomUserAgent, timestampToDate, isBadgeOnTop, isUrlInList, getTabKey, saveTabData, readTabData, initAutoExcludeList */
/* global hostHeaders, timestampToDate, isBadgeOnTop, isUrlInList, saveTabData, clearTabData, readTabData, initAutoExcludeList */
/* global isDevVersion, checkAuthentication, setupContextMenus, cropPrefix, alertMsg */

let globalAPICache = new Map()
Expand Down Expand Up @@ -333,7 +333,7 @@ function fetchAPI(url, onSuccess, onFail, postData = null) {
* @param postData {object}: uses POST if present.
* @return Promise if calls API, json data if in cache, null if loading in progress.
*/
function fetchCachedAPI(url, onSuccess, onFail, postData = null) {
function fetchCachedAPI(url, onSuccess, onFail, postData = null) {
if (typeof globalAPICache === 'undefined') { globalAPICache = new Map() }
let data = globalAPICache.get(url)
if (data === API_LOADING) {
Expand Down Expand Up @@ -1029,7 +1029,7 @@ function clearCountCache() {
* Doesn't update if cached "total" value was < 0.
* @param url {string}
*/
function incrementCount(url) {
function incrementCount(url) {
// Retrieve the waybackCountCache object from chrome.storage
chrome.storage.session.get(['waybackCountCache'], (result) => {
if (chrome.runtime.lastError) {
Expand Down Expand Up @@ -1068,7 +1068,6 @@ function clearCountCache() {
});
}


function updateWaybackCountBadge(atab, url) {
if (!atab) { return }
chrome.storage.local.get(['wm_count_setting'], (settings) => {
Expand Down Expand Up @@ -1125,31 +1124,26 @@ function setToolbarIcon(name, tabId = null) {
async function addToolbarState(atab, state) {

if (!atab) { return }
let tabKey = getTabKey(atab);
let data = await readTabData(atab);
let tbStates = toolbarStateFromTabData(data);
if (!tbStates.has(state)) {
// only save state if not already in set
tbStates.add(state);
tbStatesArray = Array.from(tbStates);
await saveTabData(atab, { states: tbStatesArray });
await saveTabData(atab, { states: Array.from(tbStates) });
}
updateToolbar(atab, tbStates);
}


// Remove state from the state set for given Tab, and update toolbar.
async function removeToolbarState(atab, state) {

if (!atab) { return }
let tabKey = getTabKey(atab);
let data = await readTabData(atab);
let tbStates = toolbarStateFromTabData(data);
if (tbStates.has(state)) {
// only save state if state to remove was in set
tbStates.delete(state);
tbStatesArray = Array.from(tbStates);
await saveTabData(atab, { states: tbStatesArray });
await saveTabData(atab, { states: Array.from(tbStates) });
}
updateToolbar(atab, tbStates);
}
Expand Down Expand Up @@ -1177,12 +1171,10 @@ async function getToolbarState(atab) {
async function clearToolbarState(atab) {

if (!atab) { return }
const tabKey = getTabKey(atab);
await clearTabData(atab, ['states']);
updateToolbar(atab, null);
}


/**
* Updates the toolbar icon using the Set of states provided.
* Only updates icon if atab is the currently active tab, else does nothing.
Expand Down Expand Up @@ -1214,7 +1206,6 @@ function updateToolbar(atab, states) {
});
}


/* * * Right-click Menu * * */

// Right-click context menu "Wayback Machine" inside the page.
Expand Down
11 changes: 5 additions & 6 deletions webextension/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function getUserInfo() {
}
})
.catch((e) => {
console.log("getUserInfo ERROR: ", e)
console.log('getUserInfo ERROR: ', e)
})
}

Expand Down Expand Up @@ -385,7 +385,7 @@ function wmAvailabilityCheck(url, onsuccess, onfail) {
})
.catch((err) => {
// catch the error in case of api failure
console.log("wmAvailabilityCheck ERROR: ", err)
console.log('wmAvailabilityCheck ERROR: ', err)
})
}

Expand Down Expand Up @@ -675,9 +675,8 @@ function opener(url, option, callback) {
}
})
} else {

chrome.windows.getCurrent({populate: true}, (window) => {
// Access window properties
chrome.windows.getCurrent({ populate: true }, (window) => {
// Access window properties
let h = window.width;
let w = window.height;
if (w > h) {
Expand Down Expand Up @@ -731,7 +730,7 @@ function checkLastError() {
if (chrome.runtime.lastError.message.startsWith('No tab with id:')) {
// Skip
} else {
console.log("checkLastError: ", chrome.runtime.lastError.message)
console.log('checkLastError: ', chrome.runtime.lastError.message)
// console.trace() // uncomment while debugging
}
} else {
Expand Down

0 comments on commit 7898148

Please sign in to comment.