Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sblask committed Nov 20, 2023
1 parent 9b7f795 commit 05aafbd
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 71 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

61 changes: 0 additions & 61 deletions .eslintrc.json

This file was deleted.

5 changes: 3 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ repos:
types_or:
- javascript
additional_dependencies:
- [email protected]
- "@stylistic/[email protected]"
- "@eslint/[email protected]"
- "@stylistic/[email protected]"
- [email protected]
- [email protected]

- id: web-ext lint
name: web-ext lint
Expand Down
14 changes: 7 additions & 7 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const OPTION_DEFAULTS = {
};

let currentTab = undefined;
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => { currentTab = tabs[0].id; });
browser.tabs.query({active: true, currentWindow: true}).then((tabs) => { currentTab = tabs[0].id; });
browser.tabs.onActivated.addListener((activeInfo) => { currentTab = activeInfo.tabId; });
browser.windows.onFocusChanged.addListener((windowId) => {
browser.tabs.query({ active: true, windowId: windowId }).then((tabs) => { currentTab = tabs[0].id; });
browser.tabs.query({active: true, windowId: windowId}).then((tabs) => { currentTab = tabs[0].id; });
});

const state = {};
Expand All @@ -26,14 +26,14 @@ browser.commands.onCommand.addListener(function(command) {
if (command == "cycle-through-linked-images") {
browser.storage.local.get(["linkedImagesRegexp"])
.then((result) => {
prepareAndGoForward(extractLinks, { regexp: result.linkedImagesRegexp });
prepareAndGoForward(extractLinks, {regexp: result.linkedImagesRegexp});
});
}

if (command == "cycle-through-embedded-images") {
browser.storage.local.get(["minWidth", "minHeight"])
.then((result) => {
prepareAndGoForward(extractImages, { minWidth: result.minWidth, minHeight: result.minHeight });
prepareAndGoForward(extractImages, {minWidth: result.minWidth, minHeight: result.minHeight});
});
}

Expand Down Expand Up @@ -94,7 +94,7 @@ function prepareAndGoForward(extractorFunction, extractorFunctionArguments) {
`,
}
);
const getOrigin = browser.tabs.executeScript(currentTab, { code: "document.URL" });
const getOrigin = browser.tabs.executeScript(currentTab, {code: "document.URL"});

Promise.all([getURLsAndReferers, getOrigin])
.then((result) => {
Expand Down Expand Up @@ -171,7 +171,7 @@ function goForward() {

browser.webRequest.onBeforeSendHeaders.addListener(addReferer, {urls: [url]}, ["blocking", "requestHeaders"]);
browser.webRequest.onBeforeRedirect.addListener(handleRedirects, {urls: [url]});
browser.tabs.update(currentTab, { url: url });
browser.tabs.update(currentTab, {url: url});
}

browser.webNavigation.onCommitted.addListener(
Expand Down Expand Up @@ -202,5 +202,5 @@ function goToOrigin() {
return;
}

browser.tabs.update(currentTab, { url: tabData.origin });
browser.tabs.update(currentTab, {url: tabData.origin});
}
88 changes: 88 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
const globals = require("globals");
const js = require("@eslint/js");
const stylistic = require("@stylistic/eslint-plugin-js");

module.exports = [
{
ignores: [
"base64.js",
"browser-polyfill.js",
],
languageOptions: {
globals: {
...globals.browser,
...globals.commonjs,
...globals.es6,
...globals.jquery,
...globals.webextensions,
},
parserOptions: {
ecmaVersion: 2020,
},
},
plugins: {
stylistic: stylistic,
},
rules:{
...js.configs.recommended.rules,
"no-restricted-syntax": [
"error",
"ForInStatement",
],
"no-unused-vars": [
"error",
{
"args": "all",
"argsIgnorePattern": "^_[^_]",
"varsIgnorePattern": "^_[^_]",
},
],
"no-var": "error",
"prefer-const": "error",
"stylistic/array-bracket-newline": [
"error",
"consistent",
],
"stylistic/array-bracket-spacing": [
"error",
"never",
],
"stylistic/comma-dangle": [
"error",
{
"arrays": "always-multiline",
"exports": "always-multiline",
"functions": "only-multiline",
"imports": "always-multiline",
"objects": "always-multiline",
},
],
"stylistic/indent": [
"error",
4,
{
"SwitchCase": 1,
},
],
"stylistic/linebreak-style": [
"error",
"unix",
],
"stylistic/no-console": [
"off",
],
"stylistic/object-curly-spacing": [
"error",
"never",
],
"stylistic/quotes": [
"error",
"double",
],
"stylistic/semi": [
"error",
"always",
],
},
},
];

0 comments on commit 05aafbd

Please sign in to comment.