Skip to content

Commit

Permalink
Merge pull request #130 from modos189/update-deps
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
modos189 authored Feb 7, 2024
2 parents 8914b38 + 1d74fb3 commit d0a72b6
Show file tree
Hide file tree
Showing 46 changed files with 7,157 additions and 19,590 deletions.
15 changes: 10 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ module.exports = {
root: true,
env: {
node: true,
webextensions: true
webextensions: true,
},
extends: ["plugin:vue/essential", "eslint:recommended", "@vue/prettier"],
extends: [
"plugin:vue/essential",
"eslint:recommended",
"plugin:prettier/recommended",
],
parserOptions: {
parser: "babel-eslint"
parser: "@babel/eslint-parser",
},
rules: {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off"
}
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
"vue/multi-word-component-names": "off",
},
};
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
presets: ["@vue/cli-plugin-babel/preset"]
presets: ["@vue/cli-plugin-babel/preset"],
};
26,143 changes: 6,838 additions & 19,305 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 14 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,27 @@
},
"dependencies": {
"@highlightjs/vue-plugin": "^1.0.2",
"core-js": "^3.6.5",
"core-js": "^3.8.3",
"highlight.js": "^10.7.3",
"jszip": "^3.10.1",
"lib-iitc-manager": "^1.8.4",
"scored-fuzzysearch": "^1.0.5",
"vue": "^2.6.11"
"vue": "^2.6.14"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"@vue/eslint-config-prettier": "^6.0.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-vue": "^6.2.2",
"prettier": "^1.19.1",
"vue-cli-plugin-browser-extension": "^0.25.1",
"vue-template-compiler": "^2.6.11"
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-vue": "^8.0.3",
"prettier": "^2.4.1",
"vue-cli-plugin-browser-extension": "^0.26.1",
"vue-template-compiler": "^2.6.14",
"webextension-polyfill": "^0.10.0"
},
"readme": "README.md"
}
31 changes: 16 additions & 15 deletions src/background/background.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
//@license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3
import { Manager } from "lib-iitc-manager";
import browser from "webextension-polyfill";
import { _ } from "@/i18n";
import { inject_plugin } from "./injector";
import {
onUpdatedListener,
onRemovedListener,
onRequestOpenIntel,
onToggleIITC
onToggleIITC,
} from "./intel";
import "./requests";
import { strToBase64 } from "@/strToBase64";
Expand All @@ -18,26 +19,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();
Expand All @@ -48,7 +49,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();
Expand All @@ -62,7 +63,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);
Expand All @@ -83,7 +84,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 {
Expand All @@ -95,7 +96,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 {
Expand All @@ -107,7 +108,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 {
Expand All @@ -122,7 +123,7 @@ browser.runtime.onMessage.addListener(async function(request) {
data: await manager.setBackupData(
request.params,
request.backup_data
)
),
})
.then();
} catch {
Expand All @@ -144,7 +145,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 = `
Expand All @@ -155,21 +156,21 @@ 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}`);

Check warning on line 162 in src/background/background.js

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
}
}

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);
};
Expand Down
7 changes: 4 additions & 3 deletions src/background/injector.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
//@license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3

import browser from "webextension-polyfill";
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);
};

Expand All @@ -26,7 +27,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}`);

Check warning on line 33 in src/background/injector.js

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
Expand All @@ -38,7 +39,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;
});
}
5 changes: 3 additions & 2 deletions src/background/intel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3
import browser from "webextension-polyfill";
import { getTabsToInject } from "./injector";

let lastIITCTab = null;
Expand All @@ -14,7 +15,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) {
Expand Down Expand Up @@ -62,7 +63,7 @@ async function initialize(manager) {

async function setTabActive(tabId) {
const tab = await browser.tabs.update(tabId, {
active: true
active: true,
});

try {
Expand Down
19 changes: 10 additions & 9 deletions src/background/requests.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
//@license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3

import browser from "webextension-polyfill";
import { parseMeta, ajaxGet, getUniqId } from "lib-iitc-manager";

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 = {};
Expand Down Expand Up @@ -66,7 +67,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;
Expand Down Expand Up @@ -107,7 +108,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}`),
});
}

Expand All @@ -119,7 +120,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 (
Expand All @@ -133,7 +134,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];
});

Expand All @@ -149,9 +150,9 @@ if (browser.webRequest) {
"*://*/*.user.js",
"*://*/*.user.js?*",
"file://*/*.user.js",
"file://*/*.user.js?*"
"file://*/*.user.js?*",
],
types: ["main_frame"]
types: ["main_frame"],
},
["blocking"]
);
Expand Down
13 changes: 7 additions & 6 deletions src/content-scripts/bridge.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//@license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3

import browser from "webextension-polyfill";
import { inject } from "@/content-scripts/utils";
import { strToBase64 } from "@/strToBase64";

Expand All @@ -24,17 +25,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) {
Expand All @@ -44,7 +45,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 = `
Expand All @@ -56,13 +57,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);
};
Loading

0 comments on commit d0a72b6

Please sign in to comment.