From 1a393e82a4102048dd027d918d74b4ddfa6c38e1 Mon Sep 17 00:00:00 2001 From: Alexander Danilov Date: Fri, 2 Feb 2024 21:35:58 +0600 Subject: [PATCH] Update eslint styles --- babel.config.js | 2 +- src/background/background.js | 30 +++++----- src/background/injector.js | 6 +- src/background/intel.js | 4 +- src/background/requests.js | 18 +++--- src/content-scripts/bridge.js | 12 ++-- src/content-scripts/gm-api.js | 60 +++++++++---------- src/content-scripts/loader.js | 8 +-- src/content-scripts/utils.js | 2 +- src/jsview/App.vue | 8 +-- src/jsview/Code.vue | 8 +-- src/jsview/Header.vue | 38 ++++++------ src/jsview/highlightjs-lineToDiv.js | 6 +- src/jsview/main.js | 2 +- src/popup/App.vue | 8 +-- src/popup/components/Element.vue | 6 +- src/popup/components/ElementPlugin.vue | 29 ++++----- src/popup/components/Header.vue | 6 +- src/popup/components/InputCustomServer.vue | 22 +++---- src/popup/components/Message.vue | 8 +-- src/popup/components/ProgressBar.vue | 6 +- src/popup/components/SearchBar.vue | 8 +-- src/popup/components/SectionMainMenu.vue | 18 +++--- src/popup/components/SectionOptions.vue | 18 +++--- src/popup/components/SectionPlugins.vue | 4 +- src/popup/components/Title.vue | 8 +-- src/popup/components/ToggleIITC.vue | 14 ++--- .../UpdateCheckIntervalSelector.vue | 13 ++-- src/popup/components/mixins.js | 26 ++++---- src/popup/data.js | 12 ++-- src/popup/main.js | 2 +- src/popup/search.js | 8 +-- src/settings/App.vue | 8 +-- src/settings/Header.vue | 6 +- src/settings/add/BlockDrop.vue | 24 ++++---- src/settings/add/BlockURL.vue | 12 ++-- src/settings/add/Main.vue | 4 +- src/settings/backup/Main.vue | 18 +++--- src/settings/backup/utils.js | 8 +-- src/settings/debug/Main.vue | 10 ++-- src/settings/main.js | 2 +- vue.config.js | 24 ++++---- 42 files changed, 268 insertions(+), 268 deletions(-) diff --git a/babel.config.js b/babel.config.js index 397abca..162a3ea 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,3 +1,3 @@ module.exports = { - presets: ["@vue/cli-plugin-babel/preset"] + presets: ["@vue/cli-plugin-babel/preset"], }; diff --git a/src/background/background.js b/src/background/background.js index 717a78d..1d153c4 100644 --- a/src/background/background.js +++ b/src/background/background.js @@ -6,7 +6,7 @@ import { onUpdatedListener, onRemovedListener, onRequestOpenIntel, - onToggleIITC + onToggleIITC, } from "./intel"; import "./requests"; import { strToBase64 } from "@/strToBase64"; @@ -18,26 +18,26 @@ const manager = new Manager({ browser.runtime .sendMessage({ type: "showMessage", - message: _(message, args) + message: _(message, args), }) .then(); } catch { // If popup is closed, message goes nowhere and an error occurs. Ignore. } }, - progressbar: is_show => { + progressbar: (is_show) => { try { browser.runtime .sendMessage({ type: "showProgressbar", - value: is_show + value: is_show, }) .then(); } catch { // If popup is closed, message goes nowhere and an error occurs. Ignore. } }, - inject_plugin: plugin => inject_plugin(plugin).then() + inject_plugin: (plugin) => inject_plugin(plugin).then(), }); manager.run().then(); @@ -48,7 +48,7 @@ onUpdated.addListener((tabId, status, tab) => ); onRemoved.addListener(onRemovedListener); -browser.runtime.onMessage.addListener(async request => { +browser.runtime.onMessage.addListener(async (request) => { switch (request.type) { case "requestOpenIntel": await onRequestOpenIntel(); @@ -62,7 +62,7 @@ browser.runtime.onMessage.addListener(async request => { } }); -browser.runtime.onMessage.addListener(async function(request) { +browser.runtime.onMessage.addListener(async function (request) { switch (request.type) { case "managePlugin": await manager.managePlugin(request.uid, request.action); @@ -83,7 +83,7 @@ browser.runtime.onMessage.addListener(async function(request) { browser.runtime .sendMessage({ type: "resolveAddUserScripts", - scripts: await manager.addUserScripts(request.scripts) + scripts: await manager.addUserScripts(request.scripts), }) .then(); } catch { @@ -95,7 +95,7 @@ browser.runtime.onMessage.addListener(async function(request) { browser.runtime .sendMessage({ type: "resolveGetPluginInfo", - info: await manager.getPluginInfo(request.uid) + info: await manager.getPluginInfo(request.uid), }) .then(); } catch { @@ -107,7 +107,7 @@ browser.runtime.onMessage.addListener(async function(request) { browser.runtime .sendMessage({ type: "resolveGetBackupData", - data: await manager.getBackupData(request.params) + data: await manager.getBackupData(request.params), }) .then(); } catch { @@ -122,7 +122,7 @@ browser.runtime.onMessage.addListener(async function(request) { data: await manager.setBackupData( request.params, request.backup_data - ) + ), }) .then(); } catch { @@ -144,7 +144,7 @@ async function xmlHttpRequestHandler(data) { const detail_stringify = JSON.stringify({ task_uuid: data.task_uuid, task_type: data.task_type, - response: JSON.stringify(response) + response: JSON.stringify(response), }); const injectedCode = ` @@ -155,7 +155,7 @@ async function xmlHttpRequestHandler(data) { try { await browser.tabs.executeScript(data.tab_id, { - code: injectedCode + code: injectedCode, }); } catch (error) { console.error(`An error occurred while execute script: ${error.message}`); @@ -163,13 +163,13 @@ async function xmlHttpRequestHandler(data) { } const req = new XMLHttpRequest(); - req.onload = function() { + req.onload = function () { const response = { readyState: this.readyState, responseHeaders: this.responseHeaders, responseText: this.responseText, status: this.status, - statusText: this.statusText + statusText: this.statusText, }; xmlResponse(data.tab_id, data.onload, response); }; diff --git a/src/background/injector.js b/src/background/injector.js index 407d3b5..271db12 100644 --- a/src/background/injector.js +++ b/src/background/injector.js @@ -5,7 +5,7 @@ import { check_matching } from "lib-iitc-manager"; export async function inject_plugin(plugin) { const tabs = await getTabsToInject(); - const is_ingress_tab = url => { + const is_ingress_tab = (url) => { return /https:\/\/(intel|missions).ingress.com\/*/.test(url); }; @@ -26,7 +26,7 @@ export async function inject_plugin(plugin) { try { await browser.tabs.executeScript(tab.id, { code: inject, - runAt: "document_end" + runAt: "document_end", }); } catch (error) { console.error(`An error occurred while reloading tabs: ${error.message}`); @@ -38,7 +38,7 @@ export async function inject_plugin(plugin) { export async function getTabsToInject() { let allTabs = await browser.tabs.query({ status: "complete" }); - return allTabs.filter(function(tab) { + return allTabs.filter(function (tab) { return tab.status === "complete" && tab.url; }); } diff --git a/src/background/intel.js b/src/background/intel.js index 454749a..1b761cd 100644 --- a/src/background/intel.js +++ b/src/background/intel.js @@ -14,7 +14,7 @@ export async function onRequestOpenIntel() { try { const tab = await browser.tabs.create({ url: "https://intel.ingress.com/", - pinned: true + pinned: true, }); lastIITCTab = tab.id; } catch (error) { @@ -62,7 +62,7 @@ async function initialize(manager) { async function setTabActive(tabId) { const tab = await browser.tabs.update(tabId, { - active: true + active: true, }); try { diff --git a/src/background/requests.js b/src/background/requests.js index 7981917..91e9898 100644 --- a/src/background/requests.js +++ b/src/background/requests.js @@ -6,10 +6,10 @@ const IS_CHROME = !!global.chrome.app; const whitelist = [ "^https://github.com/[^/]*/[^/]*/raw/[^/]*/[^/]*?\\.user\\.js([?#]|$)", "^https://gist.github.com/.*?/[^/]*?.user.js([?#]|$)", - "^https://gitlab.com/[^/]*/[^/]*/(|-/)raw/[^/]*/[^/]*?\\.user\\.js([?#]|$)" -].map(re => new RegExp(re)); + "^https://gitlab.com/[^/]*/[^/]*/(|-/)raw/[^/]*/[^/]*?\\.user\\.js([?#]|$)", +].map((re) => new RegExp(re)); const blacklist = ["//(?:(?:gist.|)github.com|gitlab.com)/"].map( - re => new RegExp(re) + (re) => new RegExp(re) ); const cache = {}; @@ -66,7 +66,7 @@ async function bypass(tabId, url) { async function maybeInstallUserJs(tabId, url) { const IITC_is_enabled = await browser.storage.local .get(["IITC_is_enabled"]) - .then(data => data.IITC_is_enabled); + .then((data) => data.IITC_is_enabled); if (IITC_is_enabled === false) { await bypass(tabId, url); return; @@ -107,7 +107,7 @@ async function confirmInstall(url, code) { await browser.storage.local.set(cache); await browser.tabs.create({ - url: await browser.runtime.getURL(`/jsview.html?uniqId=${uniqId}`) + url: await browser.runtime.getURL(`/jsview.html?uniqId=${uniqId}`), }); } @@ -119,7 +119,7 @@ function matches(re) { /** * Set autoclose if userscript was opened in a new tab */ -browser.tabs.onCreated.addListener(tab => { +browser.tabs.onCreated.addListener((tab) => { const url = tab.url === "about:blank" ? tab.title : tab.url || tab.pendingUrl || ""; if ( @@ -133,7 +133,7 @@ browser.tabs.onCreated.addListener(tab => { /** * Deleting status when closing a tab */ -browser.tabs.onRemoved.addListener(tabId => { +browser.tabs.onRemoved.addListener((tabId) => { delete cache[tabId]; }); @@ -149,9 +149,9 @@ if (browser.webRequest) { "*://*/*.user.js", "*://*/*.user.js?*", "file://*/*.user.js", - "file://*/*.user.js?*" + "file://*/*.user.js?*", ], - types: ["main_frame"] + types: ["main_frame"], }, ["blocking"] ); diff --git a/src/content-scripts/bridge.js b/src/content-scripts/bridge.js index 7bad3b5..ab6fd36 100644 --- a/src/content-scripts/bridge.js +++ b/src/content-scripts/bridge.js @@ -24,17 +24,17 @@ export async function bridgeAction(e) { } } -const xmlResponseBridge = async data => { +const xmlResponseBridge = async (data) => { browser.runtime .sendMessage({ type: "xmlHttpRequestHandler", - value: data + value: data, }) .then(); }; // Sends the entire plugins scoped storage to the page context -const getStorageBridge = async req => { +const getStorageBridge = async (req) => { const all_storage = await browser.storage.local.get(null); const plugins_storage = {}; for (const key in all_storage) { @@ -44,7 +44,7 @@ const getStorageBridge = async req => { } const detail_stringify = JSON.stringify({ task_type: req.task_type, - response: JSON.stringify(plugins_storage) + response: JSON.stringify(plugins_storage), }); const injectedCode = ` @@ -56,13 +56,13 @@ const getStorageBridge = async req => { }; // Saves the value in the persistent storage in order to synchronize the data with the storage in the page context -const setValueBridge = async req => { +const setValueBridge = async (req) => { const set_data = {}; set_data[req.key] = req.value; await browser.storage.local.set(set_data); }; // Deletes the value in the persistent storage in order to synchronize the data with the storage in the page context -const delValueBridge = async req => { +const delValueBridge = async (req) => { await browser.storage.local.remove(req.key); }; diff --git a/src/content-scripts/gm-api.js b/src/content-scripts/gm-api.js index be1748a..8b09d43 100644 --- a/src/content-scripts/gm-api.js +++ b/src/content-scripts/gm-api.js @@ -1,16 +1,16 @@ //@license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3 -export const GM = function() { +export const GM = function () { const cache = {}; const defineProperty = Object.defineProperty; function base64ToStr(base64) { const binString = atob(base64); - const bytes = Uint8Array.from(binString, m => m.codePointAt(0)); + const bytes = Uint8Array.from(binString, (m) => m.codePointAt(0)); return new TextDecoder().decode(bytes); } function uuidv4() { - return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => + return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) => ( c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4))) @@ -21,76 +21,76 @@ export const GM = function() { function sendToBridge(data) { document.dispatchEvent( new CustomEvent("bridgeRequest", { - detail: data + detail: data, }) ); } const storageObj = {}; const storage = new Proxy(storageObj, { - set: function(target, key, value) { + set: function (target, key, value) { const req = { task_type: "setValue", key: key, - value: value + value: value, }; sendToBridge(req); target[key] = value; return true; }, - deleteProperty: function(target, key) { + deleteProperty: function (target, key) { const req = { task_type: "delValue", - key: key + key: key, }; sendToBridge(req); delete target[key]; - } + }, }); function initialSyncStorage() { const req = { task_uuid: uuidv4(), - task_type: "getStorage" + task_type: "getStorage", }; sendToBridge(req); } const makeFunc = (func, toString) => { defineProperty(func, "toString", { - value: toString || "[Unknown property]" + value: toString || "[Unknown property]", }); return func; }; - window.GM = function(data_key, tab_id, meta) { + window.GM = function (data_key, tab_id, meta) { initialSyncStorage(); return { info: { - script: meta + script: meta, }, - _getValueSync: function(key, default_value) { + _getValueSync: function (key, default_value) { if (!this._access("getValue")) return undefined; const items = storage[data_key + "_" + key]; return items !== undefined ? JSON.parse(items) : default_value; }, - _setValueSync: function(key, value) { + _setValueSync: function (key, value) { if (!this._access("setValue")) return undefined; storage[data_key + "_" + key] = JSON.stringify(value); }, - getValue: function(key, default_value) { + getValue: function (key, default_value) { return new Promise((resolve, reject) => { if (!this._access("getValue")) return reject; resolve(this._getValueSync(key, default_value)); }); }, - setValue: function(key, value) { + setValue: function (key, value) { return new Promise((resolve, reject) => { if (!this._access("setValue")) return reject; resolve(this._setValueSync(key, value)); }); }, - deleteValue: function(key) { + deleteValue: function (key) { return new Promise((resolve, reject) => { if (!this._access("deleteValue")) return reject; @@ -98,7 +98,7 @@ export const GM = function() { resolve(); }); }, - listValues: function() { + listValues: function () { return new Promise((resolve, reject) => { if (!this._access("listValues")) return reject; @@ -112,15 +112,15 @@ export const GM = function() { resolve(keys); }); }, - getResourceUrl: function() { + getResourceUrl: function () { return new Promise((resolve, reject) => { if (!this._access("getResourceUrl")) return reject; }); }, - openInTab: function() {}, - notification: function() {}, - setClipboard: function() {}, - xmlHttpRequest: function(details) { + openInTab: function () {}, + notification: function () {}, + setClipboard: function () {}, + xmlHttpRequest: function (details) { let data = Object.assign( { task_uuid: uuidv4(), @@ -140,7 +140,7 @@ export const GM = function() { onload: null, onprogress: null, onreadystatechange: null, - ontimeout: null + ontimeout: null, }, details ); @@ -154,14 +154,14 @@ export const GM = function() { data.tab_id = tab_id; cache[data.task_uuid] = { - callback: details.onload + callback: details.onload, }; sendToBridge(data); }, - _access: function(key) { + _access: function (key) { return ( meta.grant !== undefined && - meta.grant.some(permission => { + meta.grant.some((permission) => { return permission.substr(3) === key; }) ); @@ -175,10 +175,10 @@ export const GM = function() { if (defineAs && targetScope) targetScope[defineAs] = obj; return obj; }), - cloneInto: makeFunc(obj => obj) + cloneInto: makeFunc((obj) => obj), }; }; - document.addEventListener("bridgeResponse", function(e) { + document.addEventListener("bridgeResponse", function (e) { const detail = JSON.parse(base64ToStr(e.detail)); const uuid = detail.task_uuid; diff --git a/src/content-scripts/loader.js b/src/content-scripts/loader.js index d659068..a1dbbb7 100644 --- a/src/content-scripts/loader.js +++ b/src/content-scripts/loader.js @@ -4,10 +4,10 @@ import { inject, IITCButtonInitJS } from "./utils"; import { bridgeAction } from "@/content-scripts/bridge"; function preparePage() { - document.addEventListener("DOMContentLoaded", function() { + document.addEventListener("DOMContentLoaded", function () { if (window.location.hostname === "intel.ingress.com") { - window.onload = function() {}; - document.body.onload = function() {}; + window.onload = function () {}; + document.body.onload = function () {}; } }); @@ -20,7 +20,7 @@ function preparePage() { document.addEventListener("IITCButtonInitJS", IITCButtonInitJS); } -browser.storage.local.get(["IITC_is_enabled"]).then(data => { +browser.storage.local.get(["IITC_is_enabled"]).then((data) => { if (data["IITC_is_enabled"] !== false) { preparePage(); } diff --git a/src/content-scripts/utils.js b/src/content-scripts/utils.js index e52ff8c..8ef61cd 100644 --- a/src/content-scripts/utils.js +++ b/src/content-scripts/utils.js @@ -51,7 +51,7 @@ export async function IITCButtonInitJS(e) { // Firefox lists .user.js among our own content scripts so a space at start will group them `\n//# sourceURL=${browser.runtime.getURL( "plugins/%20" + name + ".user.js" - )}` + )}`, ].join(""); inject(injectedCode); diff --git a/src/jsview/App.vue b/src/jsview/App.vue index f70181c..c64f30c 100644 --- a/src/jsview/App.vue +++ b/src/jsview/App.vue @@ -16,17 +16,17 @@ export default { name: "App", components: { Header, - Code + Code, }, data() { return { meta: {}, code: "", - status: _("loading") + status: _("loading"), }; }, methods: { - _: _ + _: _, }, async mounted() { const uniqId = new URL(window.location.href).searchParams.get("uniqId"); @@ -41,7 +41,7 @@ export default { meta["filename"] = url.substr(url.lastIndexOf("/") + 1); this.meta = meta; this.code = code; - } + }, }; diff --git a/src/jsview/Code.vue b/src/jsview/Code.vue index 400be45..a1cb9f8 100644 --- a/src/jsview/Code.vue +++ b/src/jsview/Code.vue @@ -13,18 +13,18 @@ import "highlight.js/styles/darcula.css"; hljs.registerLanguage("javascript", javascript); hljs.addPlugin({ - "after:highlight": plugin + "after:highlight": plugin, }); export default { name: "Code", components: { - highlightjs: hljsVuePlugin.component + highlightjs: hljsVuePlugin.component, }, props: { code: String, - status: String - } + status: String, + }, }; diff --git a/src/jsview/Header.vue b/src/jsview/Header.vue index 269efa4..73b19d7 100644 --- a/src/jsview/Header.vue +++ b/src/jsview/Header.vue @@ -34,7 +34,7 @@ 'include', 'exclude-match', 'exclude', - 'grant' + 'grant', ]" v-bind:key="ki" > @@ -69,38 +69,38 @@ export default { name: "Header", props: { meta: Object, - code: String + code: String, }, data() { return { show_header: false, button_name: _("install"), domains: null, - show_details: false + show_details: false, }; }, methods: { _: _, - install: async function() { + install: async function () { const script = [{ meta: this.meta, code: this.code }]; await browser.runtime.sendMessage({ type: "addUserScripts", - scripts: script + scripts: script, }); }, - checkIfInstalled: async function() { + checkIfInstalled: async function () { const uid = getUID(this.meta); if (uid === iitc_core_uid) { this.button_name = _("reinstall"); } await browser.runtime.sendMessage({ type: "getPluginInfo", - uid: uid + uid: uid, }); }, - setListeners: function() { + setListeners: function () { const self = this; - browser.runtime.onMessage.addListener(function(request) { + browser.runtime.onMessage.addListener(function (request) { switch (request.type) { case "resolveGetPluginInfo": if (request.info) { @@ -123,35 +123,35 @@ export default { } }); }, - on_show_details: async function() { + on_show_details: async function () { this.show_details = !this.show_details; await browser.storage.local.set({ - js_view_show_details: this.show_details + js_view_show_details: this.show_details, }); - } + }, }, watch: { - meta: function() { + meta: function () { this.domains = humanize_match(this.meta); }, - code: async function() { + code: async function () { this.show_header = true; this.setListeners(); await this.checkIfInstalled(); - } + }, }, computed: { - getIcon: function() { + getIcon: function () { return this.meta["icon64"] || this.meta["icon"] || null; - } + }, }, async mounted() { - browser.storage.local.get(["js_view_show_details"]).then(data => { + browser.storage.local.get(["js_view_show_details"]).then((data) => { if (data["js_view_show_details"] === true) { this.show_details = true; } }); - } + }, }; diff --git a/src/jsview/highlightjs-lineToDiv.js b/src/jsview/highlightjs-lineToDiv.js index 8678adc..feb7882 100644 --- a/src/jsview/highlightjs-lineToDiv.js +++ b/src/jsview/highlightjs-lineToDiv.js @@ -4,7 +4,7 @@ * * https://github.com/deleterium/highlightjs-lineToDiv */ -export const plugin = result => { +export const plugin = (result) => { let className, idName; /* Configuration */ className = "line"; @@ -43,9 +43,7 @@ export const plugin = result => { // eslint-disable-next-line no-constant-condition } while (true); if (spanStack.length > 0) { - content += Array(spanStack.length) - .fill("") - .join(""); + content += Array(spanStack.length).fill("").join(""); } let retString = "
h(App) + render: (h) => h(App), }); diff --git a/src/popup/App.vue b/src/popup/App.vue index d8ddd8a..5af6833 100644 --- a/src/popup/App.vue +++ b/src/popup/App.vue @@ -42,7 +42,7 @@ export default { plugins_flat: {}, category_name: "", iitc_core: {}, - is_safari: this.detect_safari() + is_safari: this.detect_safari(), }; }, components: { SectionMainMenu, SectionOptions, SectionPlugins, Message }, @@ -55,14 +55,14 @@ export default { await data.onMessageListener(this); }, methods: { - detect_safari: function() { + detect_safari: function () { let userAgentString = navigator.userAgent; let chromeAgent = userAgentString.indexOf("Chrome") > -1; let safariAgent = userAgentString.indexOf("Safari") > -1; return safariAgent && !chromeAgent; - } - } + }, + }, }; diff --git a/src/popup/components/Element.vue b/src/popup/components/Element.vue index 20e737c..c57584e 100644 --- a/src/popup/components/Element.vue +++ b/src/popup/components/Element.vue @@ -25,13 +25,13 @@ export default { description: String, counter: String, icon_name: String, - icon_position_is_right: Boolean + icon_position_is_right: Boolean, }, methods: { item_onclick() { this.$emit("item_onclick"); - } - } + }, + }, }; diff --git a/src/popup/components/ElementPlugin.vue b/src/popup/components/ElementPlugin.vue index 7b9e6ad..a47d957 100644 --- a/src/popup/components/ElementPlugin.vue +++ b/src/popup/components/ElementPlugin.vue @@ -53,11 +53,11 @@ diff --git a/src/popup/components/Header.vue b/src/popup/components/Header.vue index cb310a0..bab06a1 100644 --- a/src/popup/components/Header.vue +++ b/src/popup/components/Header.vue @@ -18,14 +18,14 @@ export default { name: "Header", props: { header_text: String, - button_text: String + button_text: String, }, methods: { button_onclick() { this.$emit("button_onclick"); - } + }, }, - mixins: [mixin] + mixins: [mixin], }; diff --git a/src/popup/components/InputCustomServer.vue b/src/popup/components/InputCustomServer.vue index 6a9a169..093904b 100644 --- a/src/popup/components/InputCustomServer.vue +++ b/src/popup/components/InputCustomServer.vue @@ -39,12 +39,12 @@ diff --git a/src/popup/components/Message.vue b/src/popup/components/Message.vue index 68e0d13..49ff1e3 100644 --- a/src/popup/components/Message.vue +++ b/src/popup/components/Message.vue @@ -12,21 +12,21 @@ export default { name: "Message", data() { return { - message: { opened: false, text: "" } + message: { opened: false, text: "" }, }; }, mounted() { - this.$root.$on("message", msg => { + this.$root.$on("message", (msg) => { const self = this; self.$data.message.text = msg; self.$data.message.opened = true; clearTimeout(message_timeout_id); - message_timeout_id = setTimeout(function() { + message_timeout_id = setTimeout(function () { self.$data.message.opened = false; }, 3000); }); - } + }, }; diff --git a/src/popup/components/ProgressBar.vue b/src/popup/components/ProgressBar.vue index 5ab8b11..48640a6 100644 --- a/src/popup/components/ProgressBar.vue +++ b/src/popup/components/ProgressBar.vue @@ -12,14 +12,14 @@ export default { name: "ProgressBar", data() { return { - showProgressbar: false + showProgressbar: false, }; }, mounted() { - this.$root.$on("showProgressbar", status => { + this.$root.$on("showProgressbar", (status) => { this.$data.showProgressbar = status; }); - } + }, }; diff --git a/src/popup/components/SearchBar.vue b/src/popup/components/SearchBar.vue index 337ce3f..d5a1a92 100644 --- a/src/popup/components/SearchBar.vue +++ b/src/popup/components/SearchBar.vue @@ -27,15 +27,15 @@ export default { props: { value: { type: String, - required: true - } + required: true, + }, }, methods: { cancel() { this.$emit("input", ""); - } + }, }, - mixins: [mixin] + mixins: [mixin], }; diff --git a/src/popup/components/SectionMainMenu.vue b/src/popup/components/SectionMainMenu.vue index 2092f9c..0ea80cf 100644 --- a/src/popup/components/SectionMainMenu.vue +++ b/src/popup/components/SectionMainMenu.vue @@ -59,17 +59,17 @@ export default { props: { categories: Object, plugins_flat: Object, - iitc_core: Object + iitc_core: Object, }, data() { return { search_query: "", - search_results: {} + search_results: {}, }; }, mixins: [mixin], methods: { - openCategory: function(category_name) { + openCategory: function (category_name) { document.body.id = "plugins"; this.$parent.$data.category_name = category_name; @@ -83,10 +83,10 @@ export default { return category_plugins; }, {}); }, - countPlugins: function(categories, plugins) { + countPlugins: function (categories, plugins) { if (categories === undefined) return {}; - Object.keys(categories).forEach(cat => { + Object.keys(categories).forEach((cat) => { const [count_plugins, count_plugins_active] = Object.entries( plugins ).reduce( @@ -108,18 +108,18 @@ export default { categories[cat]["count_plugins_active"] = count_plugins_active; }); return categories; - } + }, }, watch: { - search_query: function(val) { + search_query: function (val) { if (val === "*") { this.search_results = this.sortIITCObj(this.plugins_flat); } else { this.search_results = searchPlugins(val, this.plugins_flat); } - } + }, }, - components: { Title, SearchBar, Element, ElementPlugin } + components: { Title, SearchBar, Element, ElementPlugin }, }; diff --git a/src/popup/components/SectionOptions.vue b/src/popup/components/SectionOptions.vue index 5cbd7a2..f7226ee 100644 --- a/src/popup/components/SectionOptions.vue +++ b/src/popup/components/SectionOptions.vue @@ -95,31 +95,31 @@ export default { name: "settings__sectionOptions", data() { return { - channel: "release" + channel: "release", }; }, mixins: [mixin], methods: { - forceUpdate: async function() { + forceUpdate: async function () { await browser.runtime.sendMessage({ type: "forceFullUpdate" }); this.showMessage(this._("updateInProgress")); - } + }, }, computed: { channelSelect: { - get: function() { + get: function () { return this.channel; }, - set: async function(channel) { + set: async function (channel) { this.$emit("update:channel", channel); this.channel = channel; this.$root.channel = channel; await browser.runtime.sendMessage({ type: "setChannel", - value: channel + value: channel, }); - } - } + }, + }, }, async mounted() { const data = await browser.storage.local.get("channel"); @@ -127,7 +127,7 @@ export default { this.channel = data.channel; } }, - components: { Hr, Header, UpdateCheckIntervalSelector, InputCustomServer } + components: { Hr, Header, UpdateCheckIntervalSelector, InputCustomServer }, }; diff --git a/src/popup/components/SectionPlugins.vue b/src/popup/components/SectionPlugins.vue index 92a5de6..296a3fc 100644 --- a/src/popup/components/SectionPlugins.vue +++ b/src/popup/components/SectionPlugins.vue @@ -26,10 +26,10 @@ export default { props: { category_name: String, categories: Object, - plugins: Object + plugins: Object, }, mixins: [mixin], - components: { Header, Element, ElementPlugin } + components: { Header, Element, ElementPlugin }, }; diff --git a/src/popup/components/Title.vue b/src/popup/components/Title.vue index 3a8b8e8..8b5ddd2 100644 --- a/src/popup/components/Title.vue +++ b/src/popup/components/Title.vue @@ -34,15 +34,15 @@ export default { name: "Title", mixins: [mixin], methods: { - openIITC: async function() { + openIITC: async function () { await browser.runtime.sendMessage({ type: "requestOpenIntel" }); window.close(); }, - openOptions: function() { + openOptions: function () { document.body.id = "options"; - } + }, }, - components: { ProgressBar, ToggleIITC } + components: { ProgressBar, ToggleIITC }, }; diff --git a/src/popup/components/ToggleIITC.vue b/src/popup/components/ToggleIITC.vue index a407758..76c0bb4 100644 --- a/src/popup/components/ToggleIITC.vue +++ b/src/popup/components/ToggleIITC.vue @@ -20,29 +20,29 @@ export default { name: "ToggleIITC", data() { return { - iitc_is_enabled: true + iitc_is_enabled: true, }; }, computed: { iitc_is_enabled_toggle: { - get: function() { + get: function () { return this.iitc_is_enabled; }, - set: async function(newValue) { + set: async function (newValue) { this.$emit("update:iitc_is_enabled", newValue); await browser.runtime.sendMessage({ type: "toggleIITC", - value: newValue + value: newValue, }); - } - } + }, + }, }, async mounted() { const data = await browser.storage.local.get("IITC_is_enabled"); if (data.IITC_is_enabled === false) { this.iitc_is_enabled = false; } - } + }, }; diff --git a/src/popup/components/UpdateCheckIntervalSelector.vue b/src/popup/components/UpdateCheckIntervalSelector.vue index 48b4076..d6f8593 100644 --- a/src/popup/components/UpdateCheckIntervalSelector.vue +++ b/src/popup/components/UpdateCheckIntervalSelector.vue @@ -17,8 +17,9 @@ v-if="channel === 'custom' || index !== 0" v-bind:key="index" v-bind:value="item.value" - >{{ item.name }} + {{ item.name }} +
@@ -31,11 +32,11 @@ export default { name: "UpdateCheckIntervalSelector", props: { title: String, - channel: String + channel: String, }, data() { return { - interval: 24 * 60 * 60 + interval: 24 * 60 * 60, }; }, mixins: [mixin], @@ -44,10 +45,10 @@ export default { await browser.runtime.sendMessage({ type: "setUpdateCheckInterval", interval: this.interval, - channel: this.channel + channel: this.channel, }); this.showMessage(this._("changesApplied")); - } + }, }, async mounted() { const key = this.channel + "_update_check_interval"; @@ -56,7 +57,7 @@ export default { if (data[key]) { this.interval = parseInt(data[key]); } - } + }, }; diff --git a/src/popup/components/mixins.js b/src/popup/components/mixins.js index be207cc..72ff2d6 100644 --- a/src/popup/components/mixins.js +++ b/src/popup/components/mixins.js @@ -7,46 +7,46 @@ export const mixin = { updateChannels: { release: { name: _("release") }, beta: { name: _("beta") }, - custom: { name: _("custom") } + custom: { name: _("custom") }, }, updateChannelsIntervals: { release: { name: _("release") }, beta: { name: _("beta") }, custom: { name: _("custom") }, - external: { name: _("anyChannel") } + external: { name: _("anyChannel") }, }, updateIntervals: [ { name: _("every5seconds"), value: "5" }, { name: _("every6hours"), value: "21600" }, { name: _("every12hours"), value: "43200" }, { name: _("everyDay"), value: "86400" }, - { name: _("everyWeek"), value: "604800" } - ] + { name: _("everyWeek"), value: "604800" }, + ], }; }, methods: { _: _, - __: function(key, item) { + __: function (key, item) { if (item === undefined || !(key in item)) return ""; const lang = browser.i18n.getUILanguage(); return key + ":" + lang in item ? item[key + ":" + lang] : item[key]; }, - objIsEmpty: function(obj) { + objIsEmpty: function (obj) { return typeof obj !== "object" || Object.keys(obj).length === 0; }, - openLink: async function(url) { + openLink: async function (url) { await browser.tabs.create({ url: url }); window.close(); }, - back: function() { + back: function () { document.body.id = "main-menu"; }, - sortIITCObj: function(obj) { + sortIITCObj: function (obj) { if (obj === undefined) { return {}; } - const arr = Object.keys(obj).map(key => obj[key]); + const arr = Object.keys(obj).map((key) => obj[key]); for (let i = 0; i < arr.length; i++) { for (let j = i + 1; j < arr.length; j++) { @@ -63,8 +63,8 @@ export const mixin = { return arr; }, - showMessage: function(msg) { + showMessage: function (msg) { this.$root.$emit("message", msg); - } - } + }, + }, }; diff --git a/src/popup/data.js b/src/popup/data.js index 8f0d316..be4fe1a 100644 --- a/src/popup/data.js +++ b/src/popup/data.js @@ -14,7 +14,7 @@ export async function init(self) { "custom_iitc_core", "release_iitc_core_user", "beta_iitc_core_user", - "custom_iitc_core_user" + "custom_iitc_core_user", ]); const channel = data.channel ? data.channel : "release"; // initialize categories @@ -67,7 +67,7 @@ function setIitcCore(appData, iitc_core, iitc_core_user) { export async function onChangedListener(self) { const appData = self.$data; - browser.storage.onChanged.addListener(async function(changes) { + browser.storage.onChanged.addListener(async function (changes) { const data = await browser.storage.local.get("channel"); const channel = data.channel ? data.channel : "release"; @@ -79,7 +79,7 @@ export async function onChangedListener(self) { channel + "_categories", channel + "_plugins_flat", channel + "_iitc_core", - channel + "_iitc_core_user" + channel + "_iitc_core_user", ]); setCategories(appData, storage[channel + "_categories"]); setPlugins(appData, storage[channel + "_plugins_flat"]); @@ -100,7 +100,7 @@ export async function onChangedListener(self) { if (key === channel + "_iitc_core_user") { const storage = await browser.storage.local.get([ - channel + "_iitc_core" + channel + "_iitc_core", ]); setIitcCore(appData, storage[channel + "_iitc_core"], new_value); } @@ -109,7 +109,7 @@ export async function onChangedListener(self) { } export async function onMessageListener(self) { - browser.runtime.onMessage.addListener(function(request) { + browser.runtime.onMessage.addListener(function (request) { switch (request.type) { case "showProgressbar": self.$root.$emit("showProgressbar", request.value); @@ -118,7 +118,7 @@ export async function onMessageListener(self) { self.showMessage(request.message); break; } - return new Promise(resolve => { + return new Promise((resolve) => { setTimeout(() => { resolve(); }, 1); diff --git a/src/popup/main.js b/src/popup/main.js index 563574e..4cfa285 100644 --- a/src/popup/main.js +++ b/src/popup/main.js @@ -4,5 +4,5 @@ import App from "./App.vue"; new Vue({ el: "#app", - render: h => h(App) + render: (h) => h(App), }); diff --git a/src/popup/search.js b/src/popup/search.js index cb54b81..12ba313 100644 --- a/src/popup/search.js +++ b/src/popup/search.js @@ -17,7 +17,7 @@ const setPluginScore = (p, q) => { return p; }; -const sortScoredPlugins = arr => { +const sortScoredPlugins = (arr) => { for (let i = 0; i < arr.length; i++) { for (let j = i + 1; j < arr.length; j++) { if (arr[i]._search_score < arr[j]._search_score) { @@ -31,9 +31,9 @@ const sortScoredPlugins = arr => { }; export function searchPlugins(query, plugins_obj) { - const plugins = Object.keys(plugins_obj).map(key => plugins_obj[key]); - const scored_plugins = plugins.map(plugin => setPluginScore(plugin, query)); + const plugins = Object.keys(plugins_obj).map((key) => plugins_obj[key]); + const scored_plugins = plugins.map((plugin) => setPluginScore(plugin, query)); const sorted_plugins = sortScoredPlugins(scored_plugins); - const result_plugins = sorted_plugins.filter(p => p._search_score); + const result_plugins = sorted_plugins.filter((p) => p._search_score); return result_plugins; } diff --git a/src/settings/App.vue b/src/settings/App.vue index 7742d67..80affcb 100644 --- a/src/settings/App.vue +++ b/src/settings/App.vue @@ -21,11 +21,11 @@ export default { Header, PageAddPlugin, PageBackup, - PageDebug + PageDebug, }, data() { return { - tab: "add" + tab: "add", }; }, methods: { @@ -37,14 +37,14 @@ export default { location.hash = "#" + tab; } this.tab = tab; - } + }, }, async mounted() { const tab = new URL(window.location.href).hash; if (tab.length > 0) { this.tab = tab.substring(1); } - } + }, }; diff --git a/src/settings/Header.vue b/src/settings/Header.vue index 6d96e5f..b6b5f4c 100644 --- a/src/settings/Header.vue +++ b/src/settings/Header.vue @@ -38,11 +38,11 @@ import { _ } from "@/i18n"; export default { name: "Header", props: { - tab: String + tab: String, }, methods: { - _: _ - } + _: _, + }, }; diff --git a/src/settings/add/BlockDrop.vue b/src/settings/add/BlockDrop.vue index 1cddbea..e372b0c 100644 --- a/src/settings/add/BlockDrop.vue +++ b/src/settings/add/BlockDrop.vue @@ -38,7 +38,7 @@ import { _ } from "@/i18n"; /* * Validation UserScript and adding to IITC Button */ -const processingFile = async fileList => { +const processingFile = async (fileList) => { const scripts = []; let message = ""; for (let i = 0; i < fileList.length; i++) { @@ -63,11 +63,11 @@ const processingFile = async fileList => { alert(message); await browser.runtime.sendMessage({ type: "addUserScripts", - scripts: scripts + scripts: scripts, }); }; -const readUploadedFileAsText = inputFile => { +const readUploadedFileAsText = (inputFile) => { const temporaryFileReader = new FileReader(); return new Promise((resolve, reject) => { @@ -87,18 +87,18 @@ export default { name: "BlockDrop", data() { return { - files: [] + files: [], }; }, methods: { _: _, - on_drop: e => { + on_drop: (e) => { processingFile(e.dataTransfer.files).then(); }, - handlePicked: e => { + handlePicked: (e) => { const target = e.target; processingFile(target.files).then(); - } + }, }, mounted() { [ @@ -108,12 +108,12 @@ export default { "dragover", "dragenter", "dragleave", - "drop" + "drop", ].forEach( - function(evt) { + function (evt) { this.$refs.fileform.addEventListener( evt, - function(e) { + function (e) { e.preventDefault(); e.stopPropagation(); }.bind(this), @@ -123,13 +123,13 @@ export default { ); this.$refs.fileform.addEventListener( "drop", - function(e) { + function (e) { for (let i = 0; i < e.dataTransfer.files.length; i++) { this.files.push(e.dataTransfer.files[i]); } }.bind(this) ); - } + }, }; diff --git a/src/settings/add/BlockURL.vue b/src/settings/add/BlockURL.vue index 2a789c1..877ab35 100644 --- a/src/settings/add/BlockURL.vue +++ b/src/settings/add/BlockURL.vue @@ -29,17 +29,17 @@ export default { name: "BlockURL", data() { return { - url: "" + url: "", }; }, methods: { _: _, - url_input_keyup: async event => { + url_input_keyup: async (event) => { if (event.key === "Enter") { await this.loadByUrl(); } }, - loadByUrl: async function() { + loadByUrl: async function () { const url = this.url; this.url = ""; @@ -68,11 +68,11 @@ export default { alert(message); await browser.runtime.sendMessage({ type: "addUserScripts", - scripts: scripts + scripts: scripts, }); } - } - } + }, + }, }; diff --git a/src/settings/add/Main.vue b/src/settings/add/Main.vue index 59124f2..abcf5e9 100644 --- a/src/settings/add/Main.vue +++ b/src/settings/add/Main.vue @@ -19,9 +19,9 @@ import { _ } from "@/i18n"; export default { name: "PageAddPlugin", methods: { - _: _ + _: _, }, - components: { BlockURL, BlockDrop } + components: { BlockURL, BlockDrop }, }; diff --git a/src/settings/backup/Main.vue b/src/settings/backup/Main.vue index 49c9daa..dc27c95 100644 --- a/src/settings/backup/Main.vue +++ b/src/settings/backup/Main.vue @@ -75,7 +75,7 @@ export default { import_external: true, export_settings: true, export_data: true, - export_external: true + export_external: true, }; }, methods: { @@ -86,8 +86,8 @@ export default { params: { settings: this.export_settings, data: this.export_data, - external: this.export_external - } + external: this.export_external, + }, }); }, async handleImport(e) { @@ -125,13 +125,13 @@ export default { params: { settings: this.import_settings, data: this.import_data, - external: this.import_external + external: this.import_external, }, - backup_data: this.backup_data + backup_data: this.backup_data, }); }, - setListeners: function() { - browser.runtime.onMessage.addListener(function(request) { + setListeners: function () { + browser.runtime.onMessage.addListener(function (request) { switch (request.type) { case "resolveGetBackupData": createBackupZip(request.data).then(); @@ -142,11 +142,11 @@ export default { this.is_wait = false; } }); - } + }, }, async mounted() { this.setListeners(); - } + }, }; diff --git a/src/settings/backup/utils.js b/src/settings/backup/utils.js index 4134e67..ad6e50e 100644 --- a/src/settings/backup/utils.js +++ b/src/settings/backup/utils.js @@ -36,10 +36,10 @@ export const saveAs = (blob, fileName) => { setTimeout(() => URL.revokeObjectURL(link.href), 7000); }; -export const getBackupDataFromZip = async file => { +export const getBackupDataFromZip = async (file) => { const backup = { external_plugins: {}, - data: {} + data: {}, }; const zip = await JSZip.loadAsync(file); @@ -71,7 +71,7 @@ export const getBackupDataFromZip = async file => { return backup; }; -export const createBackupZip = async backup => { +export const createBackupZip = async (backup) => { const zip = new JSZip(); zip.file(backup_json_name, JSON.stringify(backup.data)); @@ -86,7 +86,7 @@ export const createBackupZip = async backup => { } const filename = "iitc-backup_" + formatDate(new Date()) + ".zip"; - zip.generateAsync({ type: "blob" }).then(function(content) { + zip.generateAsync({ type: "blob" }).then(function (content) { saveAs(content, filename); }); }; diff --git a/src/settings/debug/Main.vue b/src/settings/debug/Main.vue index 67e3b51..c5b4f69 100644 --- a/src/settings/debug/Main.vue +++ b/src/settings/debug/Main.vue @@ -26,17 +26,17 @@ export default { name: "PageDebug", data() { return { - local_storage_data: "" + local_storage_data: "", }; }, methods: { _: _, async handleExport() { - const saveJson = (function() { + const saveJson = (function () { const a = document.createElement("a"); document.body.appendChild(a); a.style = "display: none"; - return function(data, fileName) { + return function (data, fileName) { const blob = new Blob([data], { type: "application/x-javascript" }), url = window.URL.createObjectURL(blob); a.href = url; @@ -47,11 +47,11 @@ export default { })(); saveJson(this.local_storage_data, "iitc-localstorage.json"); - } + }, }, async mounted() { this.local_storage_data = JSON.stringify(await browser.storage.local.get()); - } + }, }; diff --git a/src/settings/main.js b/src/settings/main.js index 0081648..f828fb8 100644 --- a/src/settings/main.js +++ b/src/settings/main.js @@ -5,5 +5,5 @@ import App from "./App.vue"; /* eslint-disable no-new */ new Vue({ el: "#app", - render: h => h(App) + render: (h) => h(App), }); diff --git a/vue.config.js b/vue.config.js index 9a62739..d6fec2e 100644 --- a/vue.config.js +++ b/vue.config.js @@ -5,41 +5,41 @@ module.exports = { background: { template: "public/browser-extension.html", entry: "src/background/background.js", - title: "background" + title: "background", }, popup: { template: "public/browser-extension.html", entry: "./src/popup/main.js", - title: "IITC Button popup" + title: "IITC Button popup", }, jsview: { template: "public/browser-extension.html", entry: "./src/jsview/main.js", title: "IITC Button view", - filename: "jsview.html" + filename: "jsview.html", }, settings: { template: "public/browser-extension.html", entry: "./src/settings/main.js", title: "IITC Button choose file", - filename: "settings.html" - } + filename: "settings.html", + }, }, pluginOptions: { browserExtension: { componentOptions: { contentScripts: { entries: { - "content-script": ["src/content-scripts/loader.js"] - } - } + "content-script": ["src/content-scripts/loader.js"], + }, + }, }, - manifestTransformer: manifest => { + manifestTransformer: (manifest) => { if (process.env.BROWSER === "safari-ios") { manifest.background.persistent = false; } return manifest; - } - } - } + }, + }, + }, };