add a prettier target
This commit is contained in:
464
.eslintrc.js
464
.eslintrc.js
@ -2,251 +2,251 @@ module.exports = {
|
||||
env: {
|
||||
browser: true,
|
||||
es6: true,
|
||||
webextensions: true
|
||||
webextensions: true,
|
||||
},
|
||||
extends: 'eslint:recommended',
|
||||
extends: "eslint:recommended",
|
||||
globals: {
|
||||
Atomics: 'readonly',
|
||||
SharedArrayBuffer: 'readonly'
|
||||
Atomics: "readonly",
|
||||
SharedArrayBuffer: "readonly",
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaVersion: 2018
|
||||
ecmaVersion: 2018,
|
||||
},
|
||||
rules: {
|
||||
'accessor-pairs': 'error',
|
||||
'array-bracket-newline': 'error',
|
||||
'array-bracket-spacing': ['error', 'never'],
|
||||
'array-callback-return': 'error',
|
||||
'array-element-newline': 'error',
|
||||
'arrow-body-style': 'error',
|
||||
'arrow-parens': ['error', 'as-needed'],
|
||||
'arrow-spacing': [
|
||||
'error',
|
||||
"accessor-pairs": "error",
|
||||
"array-bracket-newline": "error",
|
||||
"array-bracket-spacing": ["error", "never"],
|
||||
"array-callback-return": "error",
|
||||
"array-element-newline": "error",
|
||||
"arrow-body-style": "error",
|
||||
"arrow-parens": ["error", "as-needed"],
|
||||
"arrow-spacing": [
|
||||
"error",
|
||||
{
|
||||
after: true,
|
||||
before: true
|
||||
}
|
||||
before: true,
|
||||
},
|
||||
],
|
||||
'block-scoped-var': 'off',
|
||||
'block-spacing': 'error',
|
||||
'brace-style': ['error', '1tbs'],
|
||||
'callback-return': 'error',
|
||||
camelcase: 'off',
|
||||
'capitalized-comments': 'off',
|
||||
'class-methods-use-this': 'error',
|
||||
'comma-dangle': 'error',
|
||||
'comma-spacing': [
|
||||
'error',
|
||||
"block-scoped-var": "off",
|
||||
"block-spacing": "error",
|
||||
"brace-style": ["error", "1tbs"],
|
||||
"callback-return": "error",
|
||||
camelcase: "off",
|
||||
"capitalized-comments": "off",
|
||||
"class-methods-use-this": "error",
|
||||
"comma-dangle": "error",
|
||||
"comma-spacing": [
|
||||
"error",
|
||||
{
|
||||
after: true,
|
||||
before: false
|
||||
}
|
||||
before: false,
|
||||
},
|
||||
],
|
||||
'comma-style': ['error', 'last'],
|
||||
complexity: 'error',
|
||||
'computed-property-spacing': ['error', 'never'],
|
||||
'consistent-return': 'off',
|
||||
'consistent-this': 'error',
|
||||
curly: 'error',
|
||||
'default-case': 'error',
|
||||
'default-param-last': 'error',
|
||||
'dot-location': 'off',
|
||||
'dot-notation': 'off',
|
||||
'eol-last': 'error',
|
||||
eqeqeq: 'off',
|
||||
'func-call-spacing': 'error',
|
||||
'func-name-matching': 'error',
|
||||
'func-names': 'off',
|
||||
'func-style': 'off',
|
||||
'function-call-argument-newline': ['error', 'consistent'],
|
||||
'function-paren-newline': 'off',
|
||||
'generator-star-spacing': 'error',
|
||||
'global-require': 'error',
|
||||
'guard-for-in': 'error',
|
||||
'handle-callback-err': 'error',
|
||||
'id-blacklist': 'error',
|
||||
'id-length': 'error',
|
||||
'id-match': 'error',
|
||||
'implicit-arrow-linebreak': ['error', 'beside'],
|
||||
indent: 'off',
|
||||
'indent-legacy': 'off',
|
||||
'init-declarations': 'error',
|
||||
'jsx-quotes': 'error',
|
||||
'key-spacing': 'error',
|
||||
'keyword-spacing': [
|
||||
'error',
|
||||
"comma-style": ["error", "last"],
|
||||
complexity: "error",
|
||||
"computed-property-spacing": ["error", "never"],
|
||||
"consistent-return": "off",
|
||||
"consistent-this": "error",
|
||||
curly: "error",
|
||||
"default-case": "error",
|
||||
"default-param-last": "error",
|
||||
"dot-location": "off",
|
||||
"dot-notation": "off",
|
||||
"eol-last": "error",
|
||||
eqeqeq: "off",
|
||||
"func-call-spacing": "error",
|
||||
"func-name-matching": "error",
|
||||
"func-names": "off",
|
||||
"func-style": "off",
|
||||
"function-call-argument-newline": ["error", "consistent"],
|
||||
"function-paren-newline": "off",
|
||||
"generator-star-spacing": "error",
|
||||
"global-require": "error",
|
||||
"guard-for-in": "error",
|
||||
"handle-callback-err": "error",
|
||||
"id-blacklist": "error",
|
||||
"id-length": "error",
|
||||
"id-match": "error",
|
||||
"implicit-arrow-linebreak": ["error", "beside"],
|
||||
indent: "off",
|
||||
"indent-legacy": "off",
|
||||
"init-declarations": "error",
|
||||
"jsx-quotes": "error",
|
||||
"key-spacing": "error",
|
||||
"keyword-spacing": [
|
||||
"error",
|
||||
{
|
||||
after: true,
|
||||
before: true
|
||||
}
|
||||
before: true,
|
||||
},
|
||||
],
|
||||
'line-comment-position': 'error',
|
||||
'linebreak-style': ['error', 'unix'],
|
||||
'lines-around-comment': 'off',
|
||||
'lines-around-directive': 'error',
|
||||
'lines-between-class-members': 'error',
|
||||
'max-classes-per-file': 'error',
|
||||
'max-depth': 'error',
|
||||
'max-len': 'error',
|
||||
'max-lines': 'off',
|
||||
'max-lines-per-function': 'off',
|
||||
'max-nested-callbacks': 'error',
|
||||
'max-params': 'error',
|
||||
'max-statements': 'off',
|
||||
'max-statements-per-line': 'error',
|
||||
'multiline-comment-style': ['error', 'bare-block'],
|
||||
'multiline-ternary': 'error',
|
||||
'new-cap': 'off',
|
||||
'new-parens': 'error',
|
||||
'newline-after-var': 'off',
|
||||
'newline-before-return': 'off',
|
||||
'newline-per-chained-call': 'error',
|
||||
'no-alert': 'error',
|
||||
'no-array-constructor': 'error',
|
||||
'no-await-in-loop': 'error',
|
||||
'no-bitwise': 'error',
|
||||
'no-buffer-constructor': 'error',
|
||||
'no-caller': 'error',
|
||||
'no-catch-shadow': 'error',
|
||||
'no-confusing-arrow': 'error',
|
||||
'no-console': 'off',
|
||||
'no-continue': 'error',
|
||||
'no-div-regex': 'error',
|
||||
'no-duplicate-imports': 'error',
|
||||
'no-else-return': 'off',
|
||||
'no-empty-function': 'error',
|
||||
'no-eq-null': 'error',
|
||||
'no-eval': 'error',
|
||||
'no-extend-native': 'error',
|
||||
'no-extra-bind': 'error',
|
||||
'no-extra-label': 'error',
|
||||
'no-extra-parens': 'error',
|
||||
'no-floating-decimal': 'error',
|
||||
'no-implicit-coercion': 'error',
|
||||
'no-implicit-globals': 'off',
|
||||
'no-implied-eval': 'error',
|
||||
'no-import-assign': 'error',
|
||||
'no-inline-comments': 'error',
|
||||
'no-inner-declarations': 'off',
|
||||
'no-invalid-this': 'error',
|
||||
'no-iterator': 'error',
|
||||
'no-label-var': 'error',
|
||||
'no-labels': 'error',
|
||||
'no-lone-blocks': 'error',
|
||||
'no-lonely-if': 'error',
|
||||
'no-loop-func': 'error',
|
||||
'no-magic-numbers': 'off',
|
||||
'no-mixed-operators': 'error',
|
||||
'no-mixed-requires': 'error',
|
||||
'no-multi-assign': 'error',
|
||||
'no-multi-spaces': 'error',
|
||||
'no-multi-str': 'error',
|
||||
'no-multiple-empty-lines': 'error',
|
||||
'no-native-reassign': 'error',
|
||||
'no-negated-condition': 'error',
|
||||
'no-negated-in-lhs': 'error',
|
||||
'no-nested-ternary': 'error',
|
||||
'no-new': 'error',
|
||||
'no-new-func': 'error',
|
||||
'no-new-object': 'error',
|
||||
'no-new-require': 'error',
|
||||
'no-new-wrappers': 'error',
|
||||
'no-octal-escape': 'error',
|
||||
'no-param-reassign': 'error',
|
||||
'no-path-concat': 'error',
|
||||
'no-plusplus': 'error',
|
||||
'no-process-env': 'error',
|
||||
'no-process-exit': 'error',
|
||||
'no-proto': 'error',
|
||||
'no-restricted-globals': 'error',
|
||||
'no-restricted-imports': 'error',
|
||||
'no-restricted-modules': 'error',
|
||||
'no-restricted-properties': 'error',
|
||||
'no-restricted-syntax': 'error',
|
||||
'no-return-assign': 'error',
|
||||
'no-return-await': 'error',
|
||||
'no-script-url': 'error',
|
||||
'no-self-compare': 'error',
|
||||
'no-sequences': 'error',
|
||||
'no-shadow': 'error',
|
||||
'no-spaced-func': 'error',
|
||||
'no-sync': 'error',
|
||||
'no-tabs': 'error',
|
||||
'no-template-curly-in-string': 'error',
|
||||
'no-ternary': 'error',
|
||||
'no-throw-literal': 'error',
|
||||
'no-trailing-spaces': 'error',
|
||||
'no-undef-init': 'error',
|
||||
'no-undefined': 'off',
|
||||
'no-underscore-dangle': 'error',
|
||||
'no-unmodified-loop-condition': 'error',
|
||||
'no-unneeded-ternary': 'error',
|
||||
'no-unused-expressions': 'error',
|
||||
'no-unused-vars': 'off',
|
||||
'no-use-before-define': 'off',
|
||||
'no-useless-call': 'error',
|
||||
'no-useless-computed-key': 'error',
|
||||
'no-useless-concat': 'error',
|
||||
'no-useless-constructor': 'error',
|
||||
'no-useless-rename': 'error',
|
||||
'no-useless-return': 'error',
|
||||
'no-var': 'off',
|
||||
'no-void': 'error',
|
||||
'no-warning-comments': 'error',
|
||||
'no-whitespace-before-property': 'error',
|
||||
'nonblock-statement-body-position': 'error',
|
||||
'object-curly-newline': 'error',
|
||||
'object-curly-spacing': 'off',
|
||||
'object-property-newline': 'error',
|
||||
'object-shorthand': 'error',
|
||||
'one-var': 'off',
|
||||
'one-var-declaration-per-line': 'error',
|
||||
'operator-assignment': 'error',
|
||||
'operator-linebreak': 'error',
|
||||
'padded-blocks': 'off',
|
||||
'padding-line-between-statements': 'error',
|
||||
'prefer-arrow-callback': 'off',
|
||||
'prefer-const': 'off',
|
||||
'prefer-destructuring': 'off',
|
||||
'prefer-named-capture-group': 'error',
|
||||
'prefer-numeric-literals': 'error',
|
||||
'prefer-object-spread': 'error',
|
||||
'prefer-promise-reject-errors': 'error',
|
||||
'prefer-reflect': 'error',
|
||||
'prefer-regex-literals': 'error',
|
||||
'prefer-rest-params': 'error',
|
||||
'prefer-spread': 'error',
|
||||
'prefer-template': 'off',
|
||||
'quote-props': 'off',
|
||||
quotes: ['error', 'double'],
|
||||
radix: 'error',
|
||||
'require-await': 'error',
|
||||
'require-jsdoc': 'off',
|
||||
'require-unicode-regexp': 'error',
|
||||
'rest-spread-spacing': 'error',
|
||||
semi: 'error',
|
||||
'semi-spacing': 'error',
|
||||
'semi-style': ['error', 'last'],
|
||||
'sort-imports': 'error',
|
||||
'sort-keys': 'off',
|
||||
'sort-vars': 'error',
|
||||
'space-before-blocks': 'error',
|
||||
'space-before-function-paren': 'off',
|
||||
'space-in-parens': ['error', 'never'],
|
||||
'space-infix-ops': 'error',
|
||||
'space-unary-ops': 'error',
|
||||
'spaced-comment': 'off',
|
||||
strict: ['error', 'never'],
|
||||
'switch-colon-spacing': 'error',
|
||||
'symbol-description': 'error',
|
||||
'template-curly-spacing': 'error',
|
||||
'template-tag-spacing': 'error',
|
||||
'unicode-bom': ['error', 'never'],
|
||||
'valid-jsdoc': 'error',
|
||||
'vars-on-top': 'off',
|
||||
'wrap-iife': 'error',
|
||||
'wrap-regex': 'error',
|
||||
'yield-star-spacing': 'error',
|
||||
yoda: ['error', 'never']
|
||||
}
|
||||
"line-comment-position": "error",
|
||||
"linebreak-style": ["error", "unix"],
|
||||
"lines-around-comment": "off",
|
||||
"lines-around-directive": "error",
|
||||
"lines-between-class-members": "error",
|
||||
"max-classes-per-file": "error",
|
||||
"max-depth": "error",
|
||||
"max-len": "error",
|
||||
"max-lines": "off",
|
||||
"max-lines-per-function": "off",
|
||||
"max-nested-callbacks": "error",
|
||||
"max-params": "error",
|
||||
"max-statements": "off",
|
||||
"max-statements-per-line": "error",
|
||||
"multiline-comment-style": ["error", "bare-block"],
|
||||
"multiline-ternary": "error",
|
||||
"new-cap": "off",
|
||||
"new-parens": "error",
|
||||
"newline-after-var": "off",
|
||||
"newline-before-return": "off",
|
||||
"newline-per-chained-call": "error",
|
||||
"no-alert": "error",
|
||||
"no-array-constructor": "error",
|
||||
"no-await-in-loop": "error",
|
||||
"no-bitwise": "error",
|
||||
"no-buffer-constructor": "error",
|
||||
"no-caller": "error",
|
||||
"no-catch-shadow": "error",
|
||||
"no-confusing-arrow": "error",
|
||||
"no-console": "off",
|
||||
"no-continue": "error",
|
||||
"no-div-regex": "error",
|
||||
"no-duplicate-imports": "error",
|
||||
"no-else-return": "off",
|
||||
"no-empty-function": "error",
|
||||
"no-eq-null": "error",
|
||||
"no-eval": "error",
|
||||
"no-extend-native": "error",
|
||||
"no-extra-bind": "error",
|
||||
"no-extra-label": "error",
|
||||
"no-extra-parens": "error",
|
||||
"no-floating-decimal": "error",
|
||||
"no-implicit-coercion": "error",
|
||||
"no-implicit-globals": "off",
|
||||
"no-implied-eval": "error",
|
||||
"no-import-assign": "error",
|
||||
"no-inline-comments": "error",
|
||||
"no-inner-declarations": "off",
|
||||
"no-invalid-this": "error",
|
||||
"no-iterator": "error",
|
||||
"no-label-var": "error",
|
||||
"no-labels": "error",
|
||||
"no-lone-blocks": "error",
|
||||
"no-lonely-if": "error",
|
||||
"no-loop-func": "error",
|
||||
"no-magic-numbers": "off",
|
||||
"no-mixed-operators": "error",
|
||||
"no-mixed-requires": "error",
|
||||
"no-multi-assign": "error",
|
||||
"no-multi-spaces": "error",
|
||||
"no-multi-str": "error",
|
||||
"no-multiple-empty-lines": "error",
|
||||
"no-native-reassign": "error",
|
||||
"no-negated-condition": "error",
|
||||
"no-negated-in-lhs": "error",
|
||||
"no-nested-ternary": "error",
|
||||
"no-new": "error",
|
||||
"no-new-func": "error",
|
||||
"no-new-object": "error",
|
||||
"no-new-require": "error",
|
||||
"no-new-wrappers": "error",
|
||||
"no-octal-escape": "error",
|
||||
"no-param-reassign": "error",
|
||||
"no-path-concat": "error",
|
||||
"no-plusplus": "error",
|
||||
"no-process-env": "error",
|
||||
"no-process-exit": "error",
|
||||
"no-proto": "error",
|
||||
"no-restricted-globals": "error",
|
||||
"no-restricted-imports": "error",
|
||||
"no-restricted-modules": "error",
|
||||
"no-restricted-properties": "error",
|
||||
"no-restricted-syntax": "error",
|
||||
"no-return-assign": "error",
|
||||
"no-return-await": "error",
|
||||
"no-script-url": "error",
|
||||
"no-self-compare": "error",
|
||||
"no-sequences": "error",
|
||||
"no-shadow": "error",
|
||||
"no-spaced-func": "error",
|
||||
"no-sync": "error",
|
||||
"no-tabs": "error",
|
||||
"no-template-curly-in-string": "error",
|
||||
"no-ternary": "error",
|
||||
"no-throw-literal": "error",
|
||||
"no-trailing-spaces": "error",
|
||||
"no-undef-init": "error",
|
||||
"no-undefined": "off",
|
||||
"no-underscore-dangle": "error",
|
||||
"no-unmodified-loop-condition": "error",
|
||||
"no-unneeded-ternary": "error",
|
||||
"no-unused-expressions": "error",
|
||||
"no-unused-vars": "off",
|
||||
"no-use-before-define": "off",
|
||||
"no-useless-call": "error",
|
||||
"no-useless-computed-key": "error",
|
||||
"no-useless-concat": "error",
|
||||
"no-useless-constructor": "error",
|
||||
"no-useless-rename": "error",
|
||||
"no-useless-return": "error",
|
||||
"no-var": "off",
|
||||
"no-void": "error",
|
||||
"no-warning-comments": "error",
|
||||
"no-whitespace-before-property": "error",
|
||||
"nonblock-statement-body-position": "error",
|
||||
"object-curly-newline": "error",
|
||||
"object-curly-spacing": "off",
|
||||
"object-property-newline": "error",
|
||||
"object-shorthand": "error",
|
||||
"one-var": "off",
|
||||
"one-var-declaration-per-line": "error",
|
||||
"operator-assignment": "error",
|
||||
"operator-linebreak": "error",
|
||||
"padded-blocks": "off",
|
||||
"padding-line-between-statements": "error",
|
||||
"prefer-arrow-callback": "off",
|
||||
"prefer-const": "off",
|
||||
"prefer-destructuring": "off",
|
||||
"prefer-named-capture-group": "error",
|
||||
"prefer-numeric-literals": "error",
|
||||
"prefer-object-spread": "error",
|
||||
"prefer-promise-reject-errors": "error",
|
||||
"prefer-reflect": "error",
|
||||
"prefer-regex-literals": "error",
|
||||
"prefer-rest-params": "error",
|
||||
"prefer-spread": "error",
|
||||
"prefer-template": "off",
|
||||
"quote-props": "off",
|
||||
quotes: ["error", "double"],
|
||||
radix: "error",
|
||||
"require-await": "error",
|
||||
"require-jsdoc": "off",
|
||||
"require-unicode-regexp": "error",
|
||||
"rest-spread-spacing": "error",
|
||||
semi: "error",
|
||||
"semi-spacing": "error",
|
||||
"semi-style": ["error", "last"],
|
||||
"sort-imports": "error",
|
||||
"sort-keys": "off",
|
||||
"sort-vars": "error",
|
||||
"space-before-blocks": "error",
|
||||
"space-before-function-paren": "off",
|
||||
"space-in-parens": ["error", "never"],
|
||||
"space-infix-ops": "error",
|
||||
"space-unary-ops": "error",
|
||||
"spaced-comment": "off",
|
||||
strict: ["error", "never"],
|
||||
"switch-colon-spacing": "error",
|
||||
"symbol-description": "error",
|
||||
"template-curly-spacing": "error",
|
||||
"template-tag-spacing": "error",
|
||||
"unicode-bom": ["error", "never"],
|
||||
"valid-jsdoc": "error",
|
||||
"vars-on-top": "off",
|
||||
"wrap-iife": "error",
|
||||
"wrap-regex": "error",
|
||||
"yield-star-spacing": "error",
|
||||
yoda: ["error", "never"],
|
||||
},
|
||||
};
|
||||
|
3
Makefile
3
Makefile
@ -286,6 +286,9 @@ fmt-js:
|
||||
fixjsstyle manifest.json
|
||||
#find . -path ./node_modules -prune -o -name '*.json' -exec fixjsstyle --write {} \;
|
||||
|
||||
fmt-prettier:
|
||||
find . -name '*.js*' -exec $(HOME)/node_modules/.bin/prettier -w {} \;
|
||||
|
||||
lint:
|
||||
|
||||
gjslint *.js; true
|
||||
|
154
background.js
154
background.js
@ -27,7 +27,7 @@ function onContextsGot(contexts) {
|
||||
.create({
|
||||
name: titlepref,
|
||||
color: 'orange',
|
||||
icon: 'fingerprint'
|
||||
icon: 'fingerprint',
|
||||
})
|
||||
.then(onCreated, onNotCreated);
|
||||
}
|
||||
@ -36,7 +36,7 @@ function onContextsGot(contexts) {
|
||||
.create({
|
||||
name: webpref,
|
||||
color: 'red',
|
||||
icon: 'circle'
|
||||
icon: 'circle',
|
||||
})
|
||||
.then(onCreated, onNotCreated);
|
||||
}
|
||||
@ -45,7 +45,7 @@ function onContextsGot(contexts) {
|
||||
.create({
|
||||
name: routerpref,
|
||||
color: 'blue',
|
||||
icon: 'briefcase'
|
||||
icon: 'briefcase',
|
||||
})
|
||||
.then(onCreated, onNotCreated);
|
||||
}
|
||||
@ -54,7 +54,7 @@ function onContextsGot(contexts) {
|
||||
.create({
|
||||
name: tunnelpref,
|
||||
color: 'green',
|
||||
icon: 'tree'
|
||||
icon: 'tree',
|
||||
})
|
||||
.then(onCreated, onNotCreated);
|
||||
}
|
||||
@ -63,7 +63,7 @@ function onContextsGot(contexts) {
|
||||
.create({
|
||||
name: mailpref,
|
||||
color: 'yellow',
|
||||
icon: 'briefcase'
|
||||
icon: 'briefcase',
|
||||
})
|
||||
.then(onCreated, onNotCreated);
|
||||
}
|
||||
@ -72,7 +72,7 @@ function onContextsGot(contexts) {
|
||||
.create({
|
||||
name: torrentpref,
|
||||
color: 'purple',
|
||||
icon: 'chill'
|
||||
icon: 'chill',
|
||||
})
|
||||
.then(onCreated, onNotCreated);
|
||||
}
|
||||
@ -81,7 +81,7 @@ function onContextsGot(contexts) {
|
||||
.create({
|
||||
name: ircpref,
|
||||
color: 'red',
|
||||
icon: 'vacation'
|
||||
icon: 'vacation',
|
||||
})
|
||||
.then(onCreated, onNotCreated);
|
||||
}
|
||||
@ -90,7 +90,7 @@ function onContextsGot(contexts) {
|
||||
.create({
|
||||
name: muwirepref,
|
||||
color: 'turquoise',
|
||||
icon: 'gift'
|
||||
icon: 'gift',
|
||||
})
|
||||
.then(onCreated, onNotCreated);
|
||||
}
|
||||
@ -111,7 +111,7 @@ function onNotCreated(context) {
|
||||
browser.contextualIdentities.query({}).then(onContextsGot, onContextsError);
|
||||
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then(got => {
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os != 'android') {
|
||||
browser.windows.onCreated.addListener(themeWindow);
|
||||
browser.windows.onFocusChanged.addListener(themeWindow);
|
||||
@ -124,7 +124,7 @@ gettingInfo.then(got => {
|
||||
function themeWindowByTab(tabId) {
|
||||
function tabWindow(tab) {
|
||||
var gettingPlatformInfo = browser.runtime.getPlatformInfo();
|
||||
gettingPlatformInfo.then(got => {
|
||||
gettingPlatformInfo.then((got) => {
|
||||
if (got.os == 'android') {
|
||||
let getwindow = browser.tabs.get(tab.tabId);
|
||||
getwindow.then(themeWindow);
|
||||
@ -167,21 +167,21 @@ function themeWindow(window) {
|
||||
browser.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: '#363A68',
|
||||
toolbar: '#363A68'
|
||||
}
|
||||
toolbar: '#363A68',
|
||||
},
|
||||
});
|
||||
} else {
|
||||
browser.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: '#363A68',
|
||||
toolbar: '#363A68'
|
||||
}
|
||||
toolbar: '#363A68',
|
||||
},
|
||||
});
|
||||
}
|
||||
if (tabInfo[0].url.startsWith('https://')) {
|
||||
browser.pageAction.setPopup({
|
||||
tabId: tabInfo[0].id,
|
||||
popup: 'security.html'
|
||||
popup: 'security.html',
|
||||
});
|
||||
//console.log("(background) tabinfo", tabInfo[0].id)
|
||||
browser.pageAction.show(tabInfo[0].id);
|
||||
@ -194,15 +194,15 @@ function themeWindow(window) {
|
||||
browser.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: '#4456B7',
|
||||
toolbar: '#4456B7'
|
||||
}
|
||||
toolbar: '#4456B7',
|
||||
},
|
||||
});
|
||||
} else {
|
||||
browser.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: '#4456B7',
|
||||
toolbar: '#4456B7'
|
||||
}
|
||||
toolbar: '#4456B7',
|
||||
},
|
||||
});
|
||||
}
|
||||
} else if (context.name == tunnelpref) {
|
||||
@ -211,15 +211,15 @@ function themeWindow(window) {
|
||||
browser.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: '#4456B7',
|
||||
toolbar: '#4456B7'
|
||||
}
|
||||
toolbar: '#4456B7',
|
||||
},
|
||||
});
|
||||
} else {
|
||||
browser.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: '#4456B7',
|
||||
toolbar: '#4456B7'
|
||||
}
|
||||
toolbar: '#4456B7',
|
||||
},
|
||||
});
|
||||
}
|
||||
} else if (context.name == mailpref) {
|
||||
@ -228,15 +228,15 @@ function themeWindow(window) {
|
||||
browser.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: '#4456B7',
|
||||
toolbar: '#4456B7'
|
||||
}
|
||||
toolbar: '#4456B7',
|
||||
},
|
||||
});
|
||||
} else {
|
||||
browser.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: '#4456B7',
|
||||
toolbar: '#4456B7'
|
||||
}
|
||||
toolbar: '#4456B7',
|
||||
},
|
||||
});
|
||||
}
|
||||
} else if (context.name == torrentpref) {
|
||||
@ -245,15 +245,15 @@ function themeWindow(window) {
|
||||
browser.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: '#4456B7',
|
||||
toolbar: '#4456B7'
|
||||
}
|
||||
toolbar: '#4456B7',
|
||||
},
|
||||
});
|
||||
} else {
|
||||
browser.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: '#4456B7',
|
||||
toolbar: '#4456B7'
|
||||
}
|
||||
toolbar: '#4456B7',
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -265,13 +265,13 @@ function themeWindow(window) {
|
||||
browser.contextualIdentities
|
||||
.get(tabInfo[0].cookieStoreId)
|
||||
.then(onContextGotTheme, onThemeError);
|
||||
}else {
|
||||
} else {
|
||||
console.log('Not active in I2P window');
|
||||
function unSetTheme(them) {
|
||||
console.log('unsetting theme', them);
|
||||
if (Object.keys(them).length > 0) {
|
||||
browser.theme.update(window.id, them.originalTheme);
|
||||
}else {
|
||||
} else {
|
||||
browser.theme.update(window.id, { colors: null });
|
||||
}
|
||||
}
|
||||
@ -281,7 +281,7 @@ function themeWindow(window) {
|
||||
|
||||
var querying = browser.tabs.query({
|
||||
currentWindow: true,
|
||||
active: true
|
||||
active: true,
|
||||
});
|
||||
querying.then(logTabs, onThemeError);
|
||||
}
|
||||
@ -298,33 +298,33 @@ function setTitle(window) {
|
||||
|
||||
if (window.incognito) {
|
||||
browser.windows.update(window.id, {
|
||||
titlePreface: titleprefpriv + ': '
|
||||
titlePreface: titleprefpriv + ': ',
|
||||
});
|
||||
} else {
|
||||
browser.windows.update(window.id, {
|
||||
titlePreface: titlepref + ': '
|
||||
titlePreface: titlepref + ': ',
|
||||
});
|
||||
}
|
||||
} else if (context.name == webpref) {
|
||||
console.log('Active in Web window');
|
||||
if (window.incognito) {
|
||||
browser.windows.update(window.id, {
|
||||
titlePreface: webprefpriv + ' - '
|
||||
titlePreface: webprefpriv + ' - ',
|
||||
});
|
||||
} else {
|
||||
browser.windows.update(window.id, {
|
||||
titlePreface: webpref + ' - '
|
||||
titlePreface: webpref + ' - ',
|
||||
});
|
||||
}
|
||||
} else if (context.name == routerpref) {
|
||||
console.log('Active in Router Console window');
|
||||
if (window.incognito) {
|
||||
browser.windows.update(window.id, {
|
||||
titlePreface: titleprefpriv + ' - ' + routerprefpriv + ': '
|
||||
titlePreface: titleprefpriv + ' - ' + routerprefpriv + ': ',
|
||||
});
|
||||
} else {
|
||||
browser.windows.update(window.id, {
|
||||
titlePreface: titlepref + ' - ' + routerpref + ': '
|
||||
titlePreface: titlepref + ' - ' + routerpref + ': ',
|
||||
});
|
||||
}
|
||||
} else if (context.name == tunnelpref) {
|
||||
@ -332,11 +332,11 @@ function setTitle(window) {
|
||||
|
||||
if (window.incognito) {
|
||||
browser.windows.update(window.id, {
|
||||
titlePreface: titleprefpriv + ' - ' + tunnelprefpriv + ': '
|
||||
titlePreface: titleprefpriv + ' - ' + tunnelprefpriv + ': ',
|
||||
});
|
||||
} else {
|
||||
browser.windows.update(window.id, {
|
||||
titlePreface: titlepref + ' - ' + tunnelpref + ': '
|
||||
titlePreface: titlepref + ' - ' + tunnelpref + ': ',
|
||||
});
|
||||
}
|
||||
} else if (context.name == mailpref) {
|
||||
@ -344,11 +344,11 @@ function setTitle(window) {
|
||||
|
||||
if (window.incognito) {
|
||||
browser.windows.update(window.id, {
|
||||
titlePreface: titleprefpriv + ' - ' + mailprefpriv + ': '
|
||||
titlePreface: titleprefpriv + ' - ' + mailprefpriv + ': ',
|
||||
});
|
||||
} else {
|
||||
browser.windows.update(window.id, {
|
||||
titlePreface: titlepref + ' - ' + mailpref + ': '
|
||||
titlePreface: titlepref + ' - ' + mailpref + ': ',
|
||||
});
|
||||
}
|
||||
} else if (context.name == torrentpref) {
|
||||
@ -356,11 +356,11 @@ function setTitle(window) {
|
||||
|
||||
if (window.incognito) {
|
||||
browser.windows.update(window.id, {
|
||||
titlePreface: titleprefpriv + ' - ' + torrentprefpriv + ': '
|
||||
titlePreface: titleprefpriv + ' - ' + torrentprefpriv + ': ',
|
||||
});
|
||||
} else {
|
||||
browser.windows.update(window.id, {
|
||||
titlePreface: titlepref + ' - ' + torrentpref + ': '
|
||||
titlePreface: titlepref + ' - ' + torrentpref + ': ',
|
||||
});
|
||||
}
|
||||
} else if (context.name == ircpref) {
|
||||
@ -368,11 +368,11 @@ function setTitle(window) {
|
||||
|
||||
if (window.incognito) {
|
||||
browser.windows.update(window.id, {
|
||||
titlePreface: ircprefpriv + ' - ' + ircprefpriv + ': '
|
||||
titlePreface: ircprefpriv + ' - ' + ircprefpriv + ': ',
|
||||
});
|
||||
} else {
|
||||
browser.windows.update(window.id, {
|
||||
titlePreface: ircpref + ' - ' + ircpref + ': '
|
||||
titlePreface: ircpref + ' - ' + ircpref + ': ',
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -387,37 +387,37 @@ function setTitle(window) {
|
||||
.then(onContextGotTitle, onContextError);
|
||||
} else if (window.incognito) {
|
||||
browser.windows.update(window.id, {
|
||||
titlePreface: ''
|
||||
titlePreface: '',
|
||||
});
|
||||
} else {
|
||||
browser.windows.update(window.id, {
|
||||
titlePreface: ''
|
||||
titlePreface: '',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var querying = browser.tabs.query({
|
||||
currentWindow: true,
|
||||
active: true
|
||||
active: true,
|
||||
});
|
||||
querying.then(logTabs, onContextError);
|
||||
}
|
||||
|
||||
var gettingListenerInfo = browser.runtime.getPlatformInfo();
|
||||
gettingListenerInfo.then(got => {
|
||||
gettingListenerInfo.then((got) => {
|
||||
function onPlatformError() {
|
||||
console.log('Error finding platform info');
|
||||
}
|
||||
if (got.os != 'android') {
|
||||
browser.tabs.onCreated.addListener(() => {
|
||||
var getting = browser.windows.getCurrent({
|
||||
populate: true
|
||||
populate: true,
|
||||
});
|
||||
getting.then(setTitle, onPlatformError);
|
||||
});
|
||||
browser.tabs.onActivated.addListener(() => {
|
||||
var getting = browser.windows.getCurrent({
|
||||
populate: true
|
||||
populate: true,
|
||||
});
|
||||
getting.then(setTitle, onPlatformError);
|
||||
});
|
||||
@ -425,24 +425,38 @@ gettingListenerInfo.then(got => {
|
||||
});
|
||||
|
||||
function handleUpdated(updateInfo) {
|
||||
function maybeSet(them){
|
||||
console.log("original theme found:", them, Object.keys(them).length)
|
||||
try{
|
||||
if ((Object.keys(them).length == 0) || them.originalTheme.colors == null && them.originalTheme.images == null && them.originalTheme.properties == null) {
|
||||
if (updateInfo.theme.colors.frame != '#4456B7' && updateInfo.theme.colors.frame != '#363A68') {
|
||||
function onSet(){
|
||||
console.log("stored theme:", updateInfo.theme)
|
||||
}
|
||||
if (updateInfo.theme.colors != null || updateInfo.theme.images != null || updateInfo.theme.properties != null ) {
|
||||
console.log("storing theme:", updateInfo.theme)
|
||||
browser.storage.local.set({"originalTheme": updateInfo.theme}).then(onSet, onError)
|
||||
function maybeSet(them) {
|
||||
console.log("original theme found:", them, Object.keys(them).length);
|
||||
try {
|
||||
if (
|
||||
Object.keys(them).length == 0 ||
|
||||
(them.originalTheme.colors == null &&
|
||||
them.originalTheme.images == null &&
|
||||
them.originalTheme.properties == null)
|
||||
) {
|
||||
if (
|
||||
updateInfo.theme.colors.frame != "#4456B7" &&
|
||||
updateInfo.theme.colors.frame != "#363A68"
|
||||
) {
|
||||
function onSet() {
|
||||
console.log("stored theme:", updateInfo.theme);
|
||||
}
|
||||
if (
|
||||
updateInfo.theme.colors != null ||
|
||||
updateInfo.theme.images != null ||
|
||||
updateInfo.theme.properties != null
|
||||
) {
|
||||
console.log("storing theme:", updateInfo.theme);
|
||||
browser.storage.local
|
||||
.set({ originalTheme: updateInfo.theme })
|
||||
.then(onSet, onError);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log("keeping stored theme:", them);
|
||||
}
|
||||
}else{
|
||||
console.log("keeping stored theme:", them)
|
||||
}
|
||||
}catch{
|
||||
console.log("theme storage error")
|
||||
} catch {
|
||||
console.log("theme storage error");
|
||||
}
|
||||
}
|
||||
browser.storage.local.get("originalTheme").then(maybeSet, onError);
|
||||
|
56
bookmarks.js
56
bookmarks.js
@ -1,5 +1,5 @@
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then(got => {
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os != 'android') {
|
||||
function bookmarks(bookmarkToolbar) {
|
||||
console.log('Setting up bookmark toolbar', bookmarkToolbar);
|
||||
@ -11,14 +11,14 @@ gettingInfo.then(got => {
|
||||
let createRhizomeBookmark = browser.bookmarks.create({
|
||||
url: 'about:I2p',
|
||||
title: 'I2P Extension Home Page',
|
||||
parentId: bookmarkToolbar[0].id
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
});
|
||||
createRhizomeBookmark.then(onCreated);
|
||||
} else {
|
||||
let createBookmark = browser.bookmarks.create({
|
||||
url: browser.runtime.getURL('home.html'),
|
||||
title: 'I2P Extension Home Page',
|
||||
parentId: bookmarkToolbar[0].id
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
});
|
||||
createBookmark.then(onCreated);
|
||||
}
|
||||
@ -39,7 +39,7 @@ gettingInfo.then(got => {
|
||||
let createBookmark = browser.bookmarks.create({
|
||||
url: 'http://localhost:7657/i2psnark',
|
||||
title: 'Bittorrent',
|
||||
parentId: bookmarkToolbar[0].id
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
});
|
||||
createBookmark.then(onCreated);
|
||||
} else {
|
||||
@ -47,7 +47,7 @@ gettingInfo.then(got => {
|
||||
url:
|
||||
'http://' + control_host + ':' + control_port + '/i2psnark',
|
||||
title: 'Bittorrent',
|
||||
parentId: bookmarkToolbar[0].id
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
});
|
||||
createRhizomeBookmark.then(onCreated);
|
||||
}
|
||||
@ -67,14 +67,14 @@ gettingInfo.then(got => {
|
||||
let createBookmark = browser.bookmarks.create({
|
||||
url: 'http://localhost:7657/home',
|
||||
title: 'I2P Console',
|
||||
parentId: bookmarkToolbar[0].id
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
});
|
||||
createBookmark.then(onCreated);
|
||||
} else {
|
||||
let createRhizomeBookmark = browser.bookmarks.create({
|
||||
url: 'http://' + control_host + ':' + control_port + '/home',
|
||||
title: 'I2P Console',
|
||||
parentId: bookmarkToolbar[0].id
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
});
|
||||
createRhizomeBookmark.then(onCreated);
|
||||
}
|
||||
@ -94,14 +94,14 @@ gettingInfo.then(got => {
|
||||
let createBookmark = browser.bookmarks.create({
|
||||
url: 'http://localhost:7657/webmail',
|
||||
title: 'Web Mail',
|
||||
parentId: bookmarkToolbar[0].id
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
});
|
||||
createBookmark.then(onCreated);
|
||||
} else {
|
||||
let createRhizomeBookmark = browser.bookmarks.create({
|
||||
url: 'http://' + control_host + ':' + control_port + '/webmail',
|
||||
title: 'Web Mail',
|
||||
parentId: bookmarkToolbar[0].id
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
});
|
||||
createRhizomeBookmark.then(onCreated);
|
||||
}
|
||||
@ -122,7 +122,7 @@ gettingInfo.then(got => {
|
||||
var createBookmark = browser.bookmarks.create({
|
||||
url: 'http://localhost:7657/i2ptunnel',
|
||||
title: 'Hidden Services Manager',
|
||||
parentId: bookmarkToolbar[0].id
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
});
|
||||
createBookmark.then(onCreated);
|
||||
} else {
|
||||
@ -130,7 +130,7 @@ gettingInfo.then(got => {
|
||||
url:
|
||||
'http://' + control_host + ':' + control_port + '/i2ptunnel',
|
||||
title: 'Hidden Services Manager',
|
||||
parentId: bookmarkToolbar[0].id
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
});
|
||||
createRhizomeBookmark.then(onCreated);
|
||||
}
|
||||
@ -152,53 +152,53 @@ gettingInfo.then(got => {
|
||||
}
|
||||
|
||||
var b0 = browser.bookmarks.search({
|
||||
title: 'I2P Extension Home Page'
|
||||
title: 'I2P Extension Home Page',
|
||||
});
|
||||
b0.then(bookHome, onRejected);
|
||||
|
||||
var b1 = browser.bookmarks.search({
|
||||
title: 'Bittorrent'
|
||||
title: 'Bittorrent',
|
||||
});
|
||||
b1.then(bookTorrent, onRejected);
|
||||
|
||||
var b2 = browser.bookmarks.search({
|
||||
title: 'Hidden Services Manager'
|
||||
title: 'Hidden Services Manager',
|
||||
});
|
||||
b2.then(bookI2PTunnel, onRejected);
|
||||
|
||||
var b3 = browser.bookmarks.search({
|
||||
title: 'Web Mail'
|
||||
title: 'Web Mail',
|
||||
});
|
||||
b3.then(bookMail, onRejected);
|
||||
|
||||
var b4 = browser.bookmarks.search({
|
||||
title: 'I2P Console'
|
||||
title: 'I2P Console',
|
||||
});
|
||||
b4.then(bookConsole, onRejected);
|
||||
}
|
||||
|
||||
var bt = browser.bookmarks.search({
|
||||
query: 'Toolbar'
|
||||
query: 'Toolbar',
|
||||
});
|
||||
|
||||
function toolDir(bookmarkToolbar) {
|
||||
var ibbt = browser.bookmarks.search('I2P Toolbar');
|
||||
function setupDir(ibbt) {
|
||||
function onToolbarCreated(node) {
|
||||
var ibt = browser.bookmarks.search('I2P Toolbar');
|
||||
ibt.then(bookmarks);
|
||||
}
|
||||
if (ibbt[0] == null) {
|
||||
var ibbt = browser.bookmarks.search('I2P Toolbar');
|
||||
function setupDir(ibbt) {
|
||||
function onToolbarCreated(node) {
|
||||
var ibt = browser.bookmarks.search('I2P Toolbar');
|
||||
ibt.then(bookmarks);
|
||||
}
|
||||
if (ibbt[0] == null) {
|
||||
let createBookmark = browser.bookmarks.create({
|
||||
title: 'I2P Toolbar',
|
||||
parentId: bookmarkToolbar[0].id
|
||||
parentId: bookmarkToolbar[0].id,
|
||||
});
|
||||
createBookmark.then(onToolbarCreated);
|
||||
}
|
||||
}
|
||||
ibbt.then(setupDir);
|
||||
}
|
||||
ibbt.then(setupDir);
|
||||
}
|
||||
bt.then(toolDir);
|
||||
bt.then(toolDir);
|
||||
|
||||
function handleCreated(id, bookmarkInfo) {
|
||||
//var propValue;
|
||||
|
2
cert.js
2
cert.js
@ -35,7 +35,7 @@ function tabCheck(tabInfo) {
|
||||
if (host.startsWith('https')) {
|
||||
contentUpdateById('AddressCertInfo', 'certPresent');
|
||||
console.log('(cert) initiating request to check server cert');
|
||||
fetch(host).then(response => {
|
||||
fetch(host).then((response) => {
|
||||
console.log('Updating cert information', response);
|
||||
});
|
||||
} else {
|
||||
|
@ -48,7 +48,7 @@ contentUpdateById('sources', 'sources');
|
||||
contentUpdateById('window-visit-releases', 'windowVisitReleases');
|
||||
contentUpdateById('releases', 'releases');
|
||||
|
||||
fetch('http://proxy.i2p').then(myJson => {
|
||||
fetch('http://proxy.i2p').then((myJson) => {
|
||||
console.log('FETCH RESULT', myJson);
|
||||
contentUpdateById('proxy-check', 'proxySuccessStatus');
|
||||
});
|
||||
|
14
context.js
14
context.js
@ -11,22 +11,22 @@ function eventHandler(event) {
|
||||
browser.tabs.create({
|
||||
windowId: windowInfo.id,
|
||||
url: 'about:blank',
|
||||
cookieStoreId: event.target.dataset.identity
|
||||
cookieStoreId: event.target.dataset.identity,
|
||||
});
|
||||
}
|
||||
if (event.target.dataset.action == 'create') {
|
||||
var creating = browser.tabs.create({
|
||||
cookieStoreId: event.target.dataset.identity
|
||||
cookieStoreId: event.target.dataset.identity,
|
||||
});
|
||||
creating.then(onCreated, onError);
|
||||
}
|
||||
if (event.target.dataset.action == 'close-all') {
|
||||
browser.tabs
|
||||
.query({
|
||||
cookieStoreId: event.target.dataset.identity
|
||||
cookieStoreId: event.target.dataset.identity,
|
||||
})
|
||||
.then(tabs => {
|
||||
browser.tabs.remove(tabs.map(rem => rem.id));
|
||||
.then((tabs) => {
|
||||
browser.tabs.remove(tabs.map((rem) => rem.id));
|
||||
});
|
||||
}
|
||||
event.preventDefault();
|
||||
@ -52,9 +52,9 @@ if (browser.contextualIdentities === undefined) {
|
||||
} else {
|
||||
browser.contextualIdentities
|
||||
.query({
|
||||
name: titlepref
|
||||
name: titlepref,
|
||||
})
|
||||
.then(identities => {
|
||||
.then((identities) => {
|
||||
if (!identities.length) {
|
||||
div.innerText = "No identities returned from the API.";
|
||||
return;
|
||||
|
@ -20,8 +20,8 @@ function routerHost(url) {
|
||||
return 'webmail';
|
||||
} else if (final.startsWith('MuWire')) {
|
||||
if (!url.includes('.png')) {
|
||||
console.log('(urlcheck) MuWire application path', final);
|
||||
return 'muwire';
|
||||
console.log('(urlcheck) MuWire application path', final);
|
||||
return 'muwire';
|
||||
}
|
||||
} else if (
|
||||
final === 'home' ||
|
||||
|
2
home.js
2
home.js
@ -1,4 +1,4 @@
|
||||
document.addEventListener('click', clickEvent => {
|
||||
document.addEventListener('click', (clickEvent) => {
|
||||
if (clickEvent.target.id === 'onboardingButtonZero') {
|
||||
flipVisibility('onboardingContentZero');
|
||||
} else if (clickEvent.target.id === 'onboardingButtonOne') {
|
||||
|
4
host.js
4
host.js
@ -81,8 +81,8 @@ function routerHost(url) {
|
||||
return 'webmail';
|
||||
} else if (final.startsWith('MuWire')) {
|
||||
if (!url.includes('.png')) {
|
||||
console.log('(urlcheck) MuWire application path', final);
|
||||
return 'muwire';
|
||||
console.log('(urlcheck) MuWire application path', final);
|
||||
return 'muwire';
|
||||
}
|
||||
} else if (
|
||||
final === 'home' ||
|
||||
|
@ -27,11 +27,11 @@ function send(
|
||||
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
|
||||
credentials: 'same-origin', // include, *same-origin, omit
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
redirect: 'follow', // manual, *follow, error
|
||||
referrerPolicy: 'no-referrer', // no-referrer, *client
|
||||
body: requestBody // body data type must match "Content-Type" header
|
||||
body: requestBody, // body data type must match "Content-Type" header
|
||||
};
|
||||
const response = await fetch(url, opts);
|
||||
return await response.json(); // parses JSON response into native JavaScript objects
|
||||
|
66
info.js
66
info.js
@ -1,6 +1,6 @@
|
||||
function checkPeerConnection() {
|
||||
let getting = browser.privacy.network.peerConnectionEnabled.get({});
|
||||
getting.then(got => {
|
||||
getting.then((got) => {
|
||||
let webrtc = got.value;
|
||||
console.log('checking webrtc', webrtc);
|
||||
if (document.getElementById('enable-web-rtc') !== null)
|
||||
@ -29,7 +29,7 @@ checkSnowflake();
|
||||
|
||||
function checkHistory() {
|
||||
let getting = browser.storage.local.get("disable_history");
|
||||
getting.then(got => {
|
||||
getting.then((got) => {
|
||||
let disable_history = got.disable_history;
|
||||
if (disable_history == undefined) {
|
||||
disable_history = false;
|
||||
@ -42,11 +42,11 @@ function checkHistory() {
|
||||
|
||||
checkHistory();
|
||||
|
||||
document.addEventListener("click", clickEvent => {
|
||||
document.addEventListener("click", (clickEvent) => {
|
||||
if (clickEvent.target.id === "window-create-help-panel") {
|
||||
let createData = {
|
||||
type: "panel",
|
||||
incognito: true
|
||||
incognito: true,
|
||||
};
|
||||
let creating = browser.tabs.create(createData);
|
||||
creating.then(() => {
|
||||
@ -55,7 +55,7 @@ document.addEventListener("click", clickEvent => {
|
||||
} else if (clickEvent.target.id === "window-create-news-panel") {
|
||||
let createData = {
|
||||
type: "panel",
|
||||
incognito: true
|
||||
incognito: true,
|
||||
};
|
||||
let creating = browser.tabs.create(createData);
|
||||
creating.then(() => {
|
||||
@ -68,7 +68,7 @@ document.addEventListener("click", clickEvent => {
|
||||
const url = "http://" + controlHost + ":" + controlPort;
|
||||
Http.open("GET", url);
|
||||
Http.send();
|
||||
Http.onreadystatechange = event => {
|
||||
Http.onreadystatechange = (event) => {
|
||||
console.log(Http.responseText);
|
||||
};
|
||||
}
|
||||
@ -80,28 +80,30 @@ document.addEventListener("click", clickEvent => {
|
||||
console.log("attempting to initiate graceful shutdown");
|
||||
RouterManager("ShutdownGraceful");
|
||||
} else if (clickEvent.target.id === "label-router-status") {
|
||||
if (document.getElementById("label-status-list").style.display !== "none"){
|
||||
if (document.getElementById("label-status-list").style.display !== "none") {
|
||||
console.log("hiding label-status-list");
|
||||
document.getElementById("label-status-list").style.display = "none"
|
||||
}else{
|
||||
document.getElementById("label-status-list").style.display = "none";
|
||||
} else {
|
||||
console.log("showing label-status-list");
|
||||
document.getElementById("label-status-list").style.display = "block"
|
||||
document.getElementById("label-status-list").style.display = "block";
|
||||
}
|
||||
} else if (clickEvent.target.id === "label-router-peers") {
|
||||
if (document.getElementById("label-peers-list").style.display !== "none"){
|
||||
if (document.getElementById("label-peers-list").style.display !== "none") {
|
||||
console.log("hiding label-peers-list");
|
||||
document.getElementById("label-peers-list").style.display = "none"
|
||||
}else{
|
||||
document.getElementById("label-peers-list").style.display = "none";
|
||||
} else {
|
||||
console.log("showing label-peers-list");
|
||||
document.getElementById("label-peers-list").style.display = "block"
|
||||
document.getElementById("label-peers-list").style.display = "block";
|
||||
}
|
||||
} else if (clickEvent.target.id === "label-router-bandwidth") {
|
||||
if (document.getElementById("label-bandwidth-list").style.display !== "none"){
|
||||
if (
|
||||
document.getElementById("label-bandwidth-list").style.display !== "none"
|
||||
) {
|
||||
console.log("hiding label-bandwidth-list");
|
||||
document.getElementById("label-bandwidth-list").style.display = "none"
|
||||
}else{
|
||||
document.getElementById("label-bandwidth-list").style.display = "none";
|
||||
} else {
|
||||
console.log("showing label-bandwidth-list");
|
||||
document.getElementById("label-bandwidth-list").style.display = "block"
|
||||
document.getElementById("label-bandwidth-list").style.display = "block";
|
||||
}
|
||||
} else if (clickEvent.target.id === "search-submit") {
|
||||
console.log("attempting to create search tab");
|
||||
@ -157,21 +159,21 @@ document.addEventListener("click", clickEvent => {
|
||||
clickEvent.preventDefault();
|
||||
});
|
||||
|
||||
window.onload = function(e){
|
||||
window.onload = function (e) {
|
||||
if (document.getElementById("label-peers-list") != null) {
|
||||
document.getElementById("label-peers-list").style.display = "none"
|
||||
document.getElementById("label-peers-list").style.display = "none";
|
||||
}
|
||||
if (document.getElementById("label-bandwidth-list") != null) {
|
||||
document.getElementById("label-bandwidth-list").style.display = "none"
|
||||
document.getElementById("label-bandwidth-list").style.display = "none";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function proxyReadiness() {
|
||||
console.log(this.responseText);
|
||||
}
|
||||
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then(got => {
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os != "android") {
|
||||
browser.history.onVisited.addListener(onVisited);
|
||||
}
|
||||
@ -196,14 +198,14 @@ function goHome() {
|
||||
let port = info.value.http.split(":")[1];
|
||||
if (port == "7644") {
|
||||
let createRhizomeData = {
|
||||
url: "about:I2p"
|
||||
url: "about:I2p",
|
||||
};
|
||||
console.log("visiting homepage");
|
||||
let creating = browser.tabs.create(createRhizomeData);
|
||||
creating.then(onTabCreated, onTabError);
|
||||
} else {
|
||||
let createData = {
|
||||
url: "home.html"
|
||||
url: "home.html",
|
||||
};
|
||||
console.log("visiting homepage");
|
||||
let creating = browser.tabs.create(createData);
|
||||
@ -221,7 +223,7 @@ function goIndex() {
|
||||
console.log("Help tab created");
|
||||
}
|
||||
let createData = {
|
||||
url: "index.html"
|
||||
url: "index.html",
|
||||
};
|
||||
console.log("visiting help");
|
||||
let creating = browser.tabs.create(createData);
|
||||
@ -249,7 +251,7 @@ function goSearch() {
|
||||
url:
|
||||
"http://yacy.idk.i2p/yacysearch.html?" +
|
||||
"query=" +
|
||||
document.getElementById("search-query").value
|
||||
document.getElementById("search-query").value,
|
||||
};
|
||||
console.log("visiting legwork");
|
||||
let creating = browser.tabs.create(createData);
|
||||
@ -267,7 +269,7 @@ function goTunnel() {
|
||||
console.log("I2PTunnel tab created");
|
||||
}
|
||||
let createData = {
|
||||
url: "http://" + routerAddr() + "/i2ptunnel"
|
||||
url: "http://" + routerAddr() + "/i2ptunnel",
|
||||
};
|
||||
console.log("visiting i2ptunnel");
|
||||
let creating = browser.tabs.create(createData);
|
||||
@ -279,7 +281,7 @@ function goMail() {
|
||||
console.log("Mail tab created");
|
||||
}
|
||||
let createData = {
|
||||
url: "http://" + routerAddr() + "/susimail"
|
||||
url: "http://" + routerAddr() + "/susimail",
|
||||
};
|
||||
console.log("visiting mail");
|
||||
let creating = browser.tabs.create(createData);
|
||||
@ -291,7 +293,7 @@ function goSnark() {
|
||||
console.log("Snark tab created");
|
||||
}
|
||||
let createData = {
|
||||
url: "http://" + routerAddr() + "/i2psnark"
|
||||
url: "http://" + routerAddr() + "/i2psnark",
|
||||
};
|
||||
console.log("visiting snark");
|
||||
let creating = browser.tabs.create(createData);
|
||||
@ -310,7 +312,7 @@ function onVisited(historyItem) {
|
||||
function onRemoved() {
|
||||
var searching = browser.history.search({
|
||||
text: historyItem.url,
|
||||
startTime: 0
|
||||
startTime: 0,
|
||||
});
|
||||
searching.then(onCleaned);
|
||||
}
|
||||
@ -327,6 +329,6 @@ if (UpdateContents !== undefined) UpdateContents();
|
||||
const minutes = 0.2;
|
||||
const interval = minutes * 60 * 1000;
|
||||
|
||||
setInterval(function() {
|
||||
setInterval(function () {
|
||||
if (UpdateContents !== undefined) UpdateContents();
|
||||
}, interval);
|
||||
|
@ -1,15 +1,14 @@
|
||||
|
||||
function gotCurrent(tab) {
|
||||
function gotTitle(title) {
|
||||
let addr = title;
|
||||
document.getElementById('TypeInfo').innerHTML = '<div class=\"AddressInfo\"><a href=\"' + addr + '\">' + addr + '</a></div>';
|
||||
document.getElementById('TypeInfo').innerHTML =
|
||||
'<div class="AddressInfo"><a href="' + addr + '">' + addr + '</a></div>';
|
||||
}
|
||||
console.log(tab);
|
||||
var gettingTitle = browser.pageAction.getTitle({
|
||||
tabId: tab[0].id
|
||||
tabId: tab[0].id,
|
||||
});
|
||||
gettingTitle.then(gotTitle);
|
||||
|
||||
}
|
||||
|
||||
function tabError(error) {
|
||||
|
@ -411,7 +411,7 @@ function onError(e) {
|
||||
}
|
||||
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then(got => {
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os != 'android') {
|
||||
chrome.storage.local.get(function(got) {
|
||||
let settings = checkStoredSettings(got);
|
||||
|
@ -1,7 +1,7 @@
|
||||
var android = false;
|
||||
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then(got => {
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os == 'android') {
|
||||
console.log('Running in Android detected');
|
||||
android = true;
|
||||
|
76
privacy.js
76
privacy.js
@ -12,10 +12,10 @@ function onSet(result) {
|
||||
risky sites in your browser */
|
||||
function disableHyperlinkAuditing() {
|
||||
var setting = browser.privacy.websites.hyperlinkAuditingEnabled.set({
|
||||
value: false
|
||||
value: false,
|
||||
});
|
||||
console.log('Disabling hyperlink auditing/val=', {
|
||||
value: false
|
||||
value: false,
|
||||
});
|
||||
setting.then(onSet);
|
||||
}
|
||||
@ -23,10 +23,10 @@ function disableHyperlinkAuditing() {
|
||||
// This enables first-party isolation
|
||||
function enableFirstPartyIsolation() {
|
||||
var setting = browser.privacy.websites.firstPartyIsolate.set({
|
||||
value: true
|
||||
value: true,
|
||||
});
|
||||
console.log('Enabling first party isolation/val=', {
|
||||
value: true
|
||||
value: true,
|
||||
});
|
||||
setting.then(onSet);
|
||||
}
|
||||
@ -36,18 +36,18 @@ function enableFirstPartyIsolation() {
|
||||
interface for now */
|
||||
function disableEvilCookies() {
|
||||
var getting = browser.privacy.websites.cookieConfig.get({});
|
||||
getting.then(got => {
|
||||
getting.then((got) => {
|
||||
var setting = browser.privacy.websites.cookieConfig.set({
|
||||
value: {
|
||||
behavior: 'reject_third_party',
|
||||
nonPersistentCookies: got.value.nonPersistentCookies
|
||||
}
|
||||
nonPersistentCookies: got.value.nonPersistentCookies,
|
||||
},
|
||||
});
|
||||
console.log('Setting cookie behavior/val=', {
|
||||
value: {
|
||||
behavior: 'reject_third_party',
|
||||
nonPersistentCookies: got.value.nonPersistentCookies
|
||||
}
|
||||
nonPersistentCookies: got.value.nonPersistentCookies,
|
||||
},
|
||||
});
|
||||
setting.then(onSet);
|
||||
});
|
||||
@ -67,10 +67,10 @@ function disableEvilCookies() {
|
||||
// this disables the use of referrer headers
|
||||
function disableReferrers() {
|
||||
var setting = browser.privacy.websites.referrersEnabled.set({
|
||||
value: false
|
||||
value: false,
|
||||
});
|
||||
console.log("Disabling referrer headers/val=", {
|
||||
value: false
|
||||
value: false,
|
||||
});
|
||||
setting.then(onSet);
|
||||
}
|
||||
@ -78,10 +78,10 @@ function disableReferrers() {
|
||||
// enable fingerprinting resistent features(letterboxing and stuff)
|
||||
function enableResistFingerprinting() {
|
||||
var setting = browser.privacy.websites.resistFingerprinting.set({
|
||||
value: true
|
||||
value: true,
|
||||
});
|
||||
console.log("Enabling resist fingerprinting/val=", {
|
||||
value: true
|
||||
value: true,
|
||||
});
|
||||
setting.then(onSet);
|
||||
}
|
||||
@ -89,10 +89,10 @@ function enableResistFingerprinting() {
|
||||
// This is essentially a blocklist of clearnet web-sites known to do bad tracking
|
||||
function enableTrackingProtection() {
|
||||
var setting = browser.privacy.websites.trackingProtectionMode.set({
|
||||
value: "always"
|
||||
value: "always",
|
||||
});
|
||||
console.log("Enabling tracking protection/val=", {
|
||||
value: "always"
|
||||
value: "always",
|
||||
});
|
||||
setting.then(onSet);
|
||||
}
|
||||
@ -101,15 +101,15 @@ function enableTrackingProtection() {
|
||||
management dependent on identifying information */
|
||||
function disableDigitalRestrictionsManagement() {
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then(got => {
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os == "win") {
|
||||
var setting = browser.privacy.websites.protectedContentEnabled.set({
|
||||
value: false
|
||||
value: false,
|
||||
});
|
||||
console.log(
|
||||
"Setting Protected Content(Digital Restrictions Management) false/val=",
|
||||
{
|
||||
value: false
|
||||
value: false,
|
||||
}
|
||||
);
|
||||
setting.then(onSet);
|
||||
@ -134,7 +134,7 @@ function ResetPeerConnection() {
|
||||
var webrtc = true;
|
||||
console.log("No snowflake plugin found, pre-disabled WebRTC");
|
||||
var rtc = browser.privacy.network.peerConnectionEnabled.set({
|
||||
value: webrtc
|
||||
value: webrtc,
|
||||
});
|
||||
rtc.then(AssurePeerConnection);
|
||||
}
|
||||
@ -151,7 +151,7 @@ function ResetPeerConnection() {
|
||||
function EnablePeerConnection() {
|
||||
var webrtc = true;
|
||||
var rtc = browser.privacy.network.peerConnectionEnabled.set({
|
||||
value: webrtc
|
||||
value: webrtc,
|
||||
});
|
||||
rtc.then(AssurePeerConnection);
|
||||
console.log("Enabled WebRTC");
|
||||
@ -160,13 +160,13 @@ function EnablePeerConnection() {
|
||||
function AssurePeerConnection() {
|
||||
function assure(webrtc) {
|
||||
browser.privacy.network.peerConnectionEnabled.set({
|
||||
value: true
|
||||
value: true,
|
||||
});
|
||||
browser.privacy.network.networkPredictionEnabled.set({
|
||||
value: false
|
||||
value: false,
|
||||
});
|
||||
chrome.privacy.network.webRTCIPHandlingPolicy.set({
|
||||
value: "disable_non_proxied_udp"
|
||||
value: "disable_non_proxied_udp",
|
||||
});
|
||||
}
|
||||
let rtc = browser.privacy.network.peerConnectionEnabled.get({});
|
||||
@ -174,7 +174,7 @@ function AssurePeerConnection() {
|
||||
}
|
||||
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then(got => {
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os == "android") {
|
||||
browser.tabs.onCreated.addListener(ResetPeerConnection);
|
||||
} else {
|
||||
@ -185,14 +185,14 @@ gettingInfo.then(got => {
|
||||
|
||||
function ResetDisableSavePasswords() {
|
||||
browser.privacy.services.passwordSavingEnabled.set({
|
||||
value: false
|
||||
value: false,
|
||||
});
|
||||
console.log("Re-disabled saved passwords");
|
||||
}
|
||||
|
||||
function EnableSavePasswords() {
|
||||
browser.privacy.services.passwordSavingEnabled.set({
|
||||
value: true
|
||||
value: true,
|
||||
});
|
||||
console.log("Enabled saved passwords");
|
||||
}
|
||||
@ -201,7 +201,7 @@ function EnableSavePasswords() {
|
||||
|
||||
var defaultSettings = {
|
||||
since: "forever",
|
||||
dataTypes: ["downloads", "passwords", "formData", "localStorage", "history"]
|
||||
dataTypes: ["downloads", "passwords", "formData", "localStorage", "history"],
|
||||
};
|
||||
|
||||
function onError(therror) {
|
||||
@ -217,7 +217,7 @@ function forgetBrowsingData(storedSettings) {
|
||||
const times = {
|
||||
hour: () => 1000 * 60 * 60,
|
||||
day: () => 1000 * 60 * 60 * 24,
|
||||
week: () => 1000 * 60 * 60 * 24 * 7
|
||||
week: () => 1000 * 60 * 60 * 24 * 7,
|
||||
};
|
||||
|
||||
const sinceMilliseconds = times[selectedSince].call();
|
||||
@ -241,7 +241,7 @@ function forgetBrowsingData(storedSettings) {
|
||||
browser.notifications.create({
|
||||
type: "basic",
|
||||
title: "Removed browsing data",
|
||||
message: `Removed ${dataTypesString}\n for I2P Browsing`
|
||||
message: `Removed ${dataTypesString}\n for I2P Browsing`,
|
||||
});
|
||||
}
|
||||
|
||||
@ -250,41 +250,41 @@ function forgetBrowsingData(storedSettings) {
|
||||
for (let item of historyItems) {
|
||||
if (i2pHost(item.url)) {
|
||||
browser.history.deleteUrl({
|
||||
url: item.url
|
||||
url: item.url,
|
||||
});
|
||||
browser.browsingData.removeCache({});
|
||||
console.log("cleared Cache");
|
||||
browser.browsingData
|
||||
.removePasswords({
|
||||
hostnames: [i2pHostName(item.url)],
|
||||
since
|
||||
since,
|
||||
})
|
||||
.then(onContextGotLog);
|
||||
console.log("cleared Passwords");
|
||||
browser.browsingData
|
||||
.removeDownloads({
|
||||
hostnames: [i2pHostName(item.url)],
|
||||
since
|
||||
since,
|
||||
})
|
||||
.then(onContextGotLog);
|
||||
console.log("cleared Downloads");
|
||||
browser.browsingData
|
||||
.removeFormData({
|
||||
hostnames: [i2pHostName(item.url)],
|
||||
since
|
||||
since,
|
||||
})
|
||||
.then(onContextGotLog);
|
||||
console.log("cleared Form Data");
|
||||
browser.browsingData
|
||||
.removeLocalStorage({
|
||||
hostnames: [i2pHostName(item.url)],
|
||||
since
|
||||
since,
|
||||
})
|
||||
.then(onContextGotLog);
|
||||
console.log("cleared Local Storage");
|
||||
|
||||
let contexts = browser.contextualIdentities.query({
|
||||
name: titlepref
|
||||
name: titlepref,
|
||||
});
|
||||
|
||||
function deepCleanCookies(cookies) {
|
||||
@ -292,7 +292,7 @@ function forgetBrowsingData(storedSettings) {
|
||||
var removing = browser.cookies.remove({
|
||||
firstPartyDomain: cookie.firstPartyDomain,
|
||||
name: cookie.name,
|
||||
url: item.url
|
||||
url: item.url,
|
||||
});
|
||||
removing.then(onContextGotLog, onError);
|
||||
}
|
||||
@ -303,7 +303,7 @@ function forgetBrowsingData(storedSettings) {
|
||||
for (let cookieStoreId of cookieStoreIds) {
|
||||
var removing = browser.cookies.getAll({
|
||||
firstPartyDomain: null,
|
||||
storeId: cookieStoreId.cookieStoreId
|
||||
storeId: cookieStoreId.cookieStoreId,
|
||||
});
|
||||
removing.then(deepCleanCookies, onError);
|
||||
}
|
||||
@ -317,7 +317,7 @@ function forgetBrowsingData(storedSettings) {
|
||||
|
||||
var searching = browser.history.search({
|
||||
text: "i2p",
|
||||
startTime: 0
|
||||
startTime: 0,
|
||||
});
|
||||
|
||||
searching.then(deepCleanHistory);
|
||||
|
40
proxy.js
40
proxy.js
@ -4,14 +4,14 @@ var routerpref = chrome.i18n.getMessage('routerPreface');
|
||||
var routerprefpriv = chrome.i18n.getMessage('routerPrefacePrivate');
|
||||
|
||||
browser.privacy.network.peerConnectionEnabled.set({
|
||||
value: true
|
||||
value: true,
|
||||
});
|
||||
|
||||
chrome.privacy.network.networkPredictionEnabled.set({
|
||||
value: false
|
||||
value: false,
|
||||
});
|
||||
chrome.privacy.network.webRTCIPHandlingPolicy.set({
|
||||
value: 'disable_non_proxied_udp'
|
||||
value: 'disable_non_proxied_udp',
|
||||
});
|
||||
console.log('Disabled unproxied UDP.');
|
||||
|
||||
@ -24,7 +24,7 @@ var handleContextProxyRequest = async function(requestDetails) {
|
||||
var handleProxyRequest = function(context) {
|
||||
proxy = {
|
||||
failoverTimeout: 0,
|
||||
proxyDns: false
|
||||
proxyDns: false,
|
||||
};
|
||||
if (context == 'firefox-default' || context == 'firefox-private') {
|
||||
proxy = null;
|
||||
@ -38,7 +38,7 @@ var handleContextProxyRequest = async function(requestDetails) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort()
|
||||
port: getPort(),
|
||||
};
|
||||
}
|
||||
return proxy;
|
||||
@ -46,7 +46,7 @@ var handleContextProxyRequest = async function(requestDetails) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort()
|
||||
port: getPort(),
|
||||
};
|
||||
} else if (context.name == routerpref) {
|
||||
if (routerHost(requestDetails.url)) {
|
||||
@ -55,7 +55,7 @@ var handleContextProxyRequest = async function(requestDetails) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort()
|
||||
port: getPort(),
|
||||
};
|
||||
}
|
||||
return proxy;
|
||||
@ -65,7 +65,7 @@ var handleContextProxyRequest = async function(requestDetails) {
|
||||
proxy = {
|
||||
type: 'http',
|
||||
host: 'localhost',
|
||||
port: '65535'
|
||||
port: '65535',
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -80,17 +80,17 @@ var handleContextProxyRequest = async function(requestDetails) {
|
||||
if (requestDetails.url.includes(':7669')) {
|
||||
proxy = null;
|
||||
} else {
|
||||
console.log(
|
||||
'(proxy) non-routerconsole localhost url, will not interfere',
|
||||
requestDetails.url
|
||||
);
|
||||
console.log(
|
||||
'(proxy) non-routerconsole localhost url, will not interfere',
|
||||
requestDetails.url
|
||||
);
|
||||
}
|
||||
}
|
||||
} else if (i2pHost(requestDetails.url)) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort()
|
||||
port: getPort(),
|
||||
};
|
||||
}
|
||||
//var tab = tabGet(requestDetails.tabId);
|
||||
@ -120,7 +120,7 @@ var handleContextProxyRequest = async function(requestDetails) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort()
|
||||
port: getPort(),
|
||||
};
|
||||
return proxy;
|
||||
}
|
||||
@ -132,7 +132,7 @@ var handleContextProxyRequest = async function(requestDetails) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort()
|
||||
port: getPort(),
|
||||
};
|
||||
return proxy;
|
||||
}
|
||||
@ -147,7 +147,7 @@ var handleContextProxyRequest = async function(requestDetails) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort()
|
||||
port: getPort(),
|
||||
};
|
||||
return proxy;
|
||||
} else if (extensionHost(requestDetails.url)) {
|
||||
@ -304,7 +304,7 @@ function getConsolePort() {
|
||||
function setupProxy() {
|
||||
console.log('Setting up Firefox WebExtension proxy');
|
||||
browser.proxy.onRequest.addListener(handleContextProxyRequest, {
|
||||
urls: ['<all_urls>']
|
||||
urls: ['<all_urls>'],
|
||||
});
|
||||
console.log('i2p settings created for WebExtension Proxy');
|
||||
}
|
||||
@ -325,9 +325,9 @@ function updateFromStorage() {
|
||||
setupProxy();
|
||||
});
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then(got => {
|
||||
gettingInfo.then((got) => {
|
||||
if (got.os != 'android') {
|
||||
browser.windows.getAll().then(wins => wins.forEach(themeWindow));
|
||||
browser.windows.getAll().then((wins) => wins.forEach(themeWindow));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -338,7 +338,7 @@ SetupSettings();
|
||||
setupProxy();
|
||||
|
||||
var gettingListenerInfo = browser.runtime.getPlatformInfo();
|
||||
gettingListenerInfo.then(got => {
|
||||
gettingListenerInfo.then((got) => {
|
||||
browser.windows.onCreated.addListener(() => {
|
||||
chrome.storage.local.get(function() {
|
||||
setupProxy();
|
||||
|
119
script.js
119
script.js
@ -1,5 +1,4 @@
|
||||
|
||||
browser.runtime.onMessage.addListener(request => {
|
||||
browser.runtime.onMessage.addListener((request) => {
|
||||
var response = '';
|
||||
if (request.req === 'i2p-location') {
|
||||
response = 'no-alt-location';
|
||||
@ -13,8 +12,7 @@ browser.runtime.onMessage.addListener(request => {
|
||||
if (tag.toUpperCase() === 'X-I2P-LOCATION') {
|
||||
response = metas[i].getAttribute('content');
|
||||
}
|
||||
}catch{
|
||||
};
|
||||
} catch {};
|
||||
}
|
||||
}
|
||||
if (request.req === 'i2p-torrentlocation') {
|
||||
@ -29,7 +27,10 @@ browser.runtime.onMessage.addListener(request => {
|
||||
for (let img of imgs) {
|
||||
let tmpsrc = new URL(img.src);
|
||||
if (tmpsrc.host == location.host) {
|
||||
img.src = 'http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;
|
||||
img.src =
|
||||
'http://127.0.0.1:7657/i2psnark/' +
|
||||
tmpsrc.host +
|
||||
tmpsrc.pathname;
|
||||
img.onerror = function() {
|
||||
img.src = tmpsrc;
|
||||
};
|
||||
@ -40,28 +41,38 @@ browser.runtime.onMessage.addListener(request => {
|
||||
for (let link of links) {
|
||||
console.log('(Changing Link)', link);
|
||||
let tmpsrc = new URL(link.href);
|
||||
// console.log("link", tmpsrc.host, tmpsrc.pathname)
|
||||
// console.log("link", tmpsrc.host, tmpsrc.pathname)
|
||||
if (tmpsrc.host == location.host) {
|
||||
if (!tmpsrc.pathname.endsWith('html') && !tmpsrc.pathname.endsWith('htm') &&
|
||||
!tmpsrc.pathname.endsWith('php') && !tmpsrc.pathname.endsWith('jsp') &&
|
||||
!tmpsrc.pathname.endsWith('asp') && !tmpsrc.pathname.endsWith('aspx') &&
|
||||
!tmpsrc.pathname.endsWith('atom') && !tmpsrc.pathname.endsWith('rss') &&
|
||||
!tmpsrc.pathname.endsWith('\/') && tmpsrc.pathname.includes('.')) {
|
||||
if (
|
||||
!tmpsrc.pathname.endsWith('html') &&
|
||||
!tmpsrc.pathname.endsWith('htm') &&
|
||||
!tmpsrc.pathname.endsWith('php') &&
|
||||
!tmpsrc.pathname.endsWith('jsp') &&
|
||||
!tmpsrc.pathname.endsWith('asp') &&
|
||||
!tmpsrc.pathname.endsWith('aspx') &&
|
||||
!tmpsrc.pathname.endsWith('atom') &&
|
||||
!tmpsrc.pathname.endsWith('rss') &&
|
||||
!tmpsrc.pathname.endsWith('/') &&
|
||||
tmpsrc.pathname.includes('.')
|
||||
) {
|
||||
console.log('link', tmpsrc.host, tmpsrc.pathname);
|
||||
link.href = 'http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;
|
||||
link.href =
|
||||
'http://127.0.0.1:7657/i2psnark/' +
|
||||
tmpsrc.host +
|
||||
tmpsrc.pathname;
|
||||
link.onerror = function() {
|
||||
window.location.href = tmpsrc.href;
|
||||
};
|
||||
}
|
||||
//if (!tmpsrc.pathname.endsWith('html')) { // && !tmpsrc.pathname.endsWith('htm') &&
|
||||
// !tmpsrc.pathname.endsWith('php') && !tmpsrc.pathname.endsWith('jsp') &&
|
||||
// !tmpsrc.pathname.endsWith('asp') && !tmpsrc.pathname.endsWith('aspx') &&
|
||||
// tmpsrc.pathname.includes('.') && !tmpsrc..pathname.endsWith('/')) {
|
||||
//console.log('http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;)
|
||||
//link.href = 'http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;
|
||||
//link.onerror = function() {
|
||||
//link.src = tmpsrc;
|
||||
//};
|
||||
// !tmpsrc.pathname.endsWith('php') && !tmpsrc.pathname.endsWith('jsp') &&
|
||||
// !tmpsrc.pathname.endsWith('asp') && !tmpsrc.pathname.endsWith('aspx') &&
|
||||
// tmpsrc.pathname.includes('.') && !tmpsrc..pathname.endsWith('/')) {
|
||||
//console.log('http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;)
|
||||
//link.href = 'http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;
|
||||
//link.onerror = function() {
|
||||
//link.src = tmpsrc;
|
||||
//};
|
||||
//}
|
||||
}
|
||||
}
|
||||
@ -71,7 +82,10 @@ browser.runtime.onMessage.addListener(request => {
|
||||
if (tmpsrc.host == location.host) {
|
||||
if (!video.innerHTML.includes('127.0.0.1')) {
|
||||
innerHTML = video.innerHTML;
|
||||
topInnerHTML = video.innerHTML.replace('src=\"', 'src=\"http://127.0.0.1:7657/i2psnark/' + location.host + '/');
|
||||
topInnerHTML = video.innerHTML.replace(
|
||||
'src="',
|
||||
'src="http://127.0.0.1:7657/i2psnark/' + location.host + '/'
|
||||
);
|
||||
video.innerHTML = topInnerHTML + innerHTML;
|
||||
}
|
||||
}
|
||||
@ -82,7 +96,10 @@ browser.runtime.onMessage.addListener(request => {
|
||||
if (tmpsrc.host == location.host) {
|
||||
if (!audio.innerHTML.includes('127.0.0.1')) {
|
||||
innerHTML = audio.innerHTML;
|
||||
topInnerHTML = audio.innerHTML.replace('src=\"', 'src=\"http://127.0.0.1:7657/i2psnark/' + location.host + '/');
|
||||
topInnerHTML = audio.innerHTML.replace(
|
||||
'src="',
|
||||
'src="http://127.0.0.1:7657/i2psnark/' + location.host + '/'
|
||||
);
|
||||
audio.innerHTML = topInnerHTML + innerHTML;
|
||||
}
|
||||
}
|
||||
@ -94,7 +111,10 @@ browser.runtime.onMessage.addListener(request => {
|
||||
for (let img of imgs) {
|
||||
let tmpsrc = new URL(img.src);
|
||||
if (tmpsrc.host == location.host) {
|
||||
img.src = 'http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;
|
||||
img.src =
|
||||
'http://127.0.0.1:7657/i2psnark/' +
|
||||
tmpsrc.host +
|
||||
tmpsrc.pathname;
|
||||
img.onerror = function() {
|
||||
img.src = tmpsrc;
|
||||
};
|
||||
@ -107,26 +127,36 @@ browser.runtime.onMessage.addListener(request => {
|
||||
let tmpsrc = new URL(link.href);
|
||||
//console.log("link", tmpsrc.host, tmpsrc.pathname)
|
||||
if (tmpsrc.host == location.host) {
|
||||
if (!tmpsrc.pathname.endsWith('html') && !tmpsrc.pathname.endsWith('htm') &&
|
||||
!tmpsrc.pathname.endsWith('php') && !tmpsrc.pathname.endsWith('jsp') &&
|
||||
!tmpsrc.pathname.endsWith('asp') && !tmpsrc.pathname.endsWith('aspx') &&
|
||||
!tmpsrc.pathname.endsWith('atom') && !tmpsrc.pathname.endsWith('rss') &&
|
||||
!tmpsrc.pathname.endsWith('\/') && tmpsrc.pathname.includes('.')) {
|
||||
if (
|
||||
!tmpsrc.pathname.endsWith('html') &&
|
||||
!tmpsrc.pathname.endsWith('htm') &&
|
||||
!tmpsrc.pathname.endsWith('php') &&
|
||||
!tmpsrc.pathname.endsWith('jsp') &&
|
||||
!tmpsrc.pathname.endsWith('asp') &&
|
||||
!tmpsrc.pathname.endsWith('aspx') &&
|
||||
!tmpsrc.pathname.endsWith('atom') &&
|
||||
!tmpsrc.pathname.endsWith('rss') &&
|
||||
!tmpsrc.pathname.endsWith('/') &&
|
||||
tmpsrc.pathname.includes('.')
|
||||
) {
|
||||
console.log('link', tmpsrc.host, tmpsrc.pathname);
|
||||
link.href = 'http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;
|
||||
link.href =
|
||||
'http://127.0.0.1:7657/i2psnark/' +
|
||||
tmpsrc.host +
|
||||
tmpsrc.pathname;
|
||||
link.onerror = function() {
|
||||
window.location.href = tmpsrc.href;
|
||||
};
|
||||
}
|
||||
//if (!tmpsrc.pathname.endsWith('html')) { // && !tmpsrc.pathname.endsWith('htm') &&
|
||||
// !tmpsrc.pathname.endsWith('php') && !tmpsrc.pathname.endsWith('jsp') &&
|
||||
// !tmpsrc.pathname.endsWith('asp') && !tmpsrc.pathname.endsWith('aspx') &&
|
||||
// tmpsrc.pathname.includes('.') && !tmpsrc..pathname.endsWith('/')) {
|
||||
//console.log('http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;)
|
||||
//link.href = 'http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;
|
||||
//link.onerror = function() {
|
||||
//link.src = tmpsrc;
|
||||
//};
|
||||
// !tmpsrc.pathname.endsWith('php') && !tmpsrc.pathname.endsWith('jsp') &&
|
||||
// !tmpsrc.pathname.endsWith('asp') && !tmpsrc.pathname.endsWith('aspx') &&
|
||||
// tmpsrc.pathname.includes('.') && !tmpsrc..pathname.endsWith('/')) {
|
||||
//console.log('http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;)
|
||||
//link.href = 'http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;
|
||||
//link.onerror = function() {
|
||||
//link.src = tmpsrc;
|
||||
//};
|
||||
//}
|
||||
}
|
||||
}
|
||||
@ -136,7 +166,10 @@ browser.runtime.onMessage.addListener(request => {
|
||||
if (tmpsrc.host == location.host) {
|
||||
if (!video.innerHTML.includes('127.0.0.1')) {
|
||||
innerHTML = video.innerHTML;
|
||||
topInnerHTML = video.innerHTML.replace('src=\"', 'src=\"http://127.0.0.1:7657/i2psnark/' + location.host + '/');
|
||||
topInnerHTML = video.innerHTML.replace(
|
||||
'src="',
|
||||
'src="http://127.0.0.1:7657/i2psnark/' + location.host + '/'
|
||||
);
|
||||
video.innerHTML = topInnerHTML + innerHTML;
|
||||
}
|
||||
}
|
||||
@ -147,15 +180,17 @@ browser.runtime.onMessage.addListener(request => {
|
||||
if (tmpsrc.host == location.host) {
|
||||
if (!audio.innerHTML.includes('127.0.0.1')) {
|
||||
innerHTML = audio.innerHTML;
|
||||
topInnerHTML = audio.innerHTML.replace('src=\"', 'src=\"http://127.0.0.1:7657/i2psnark/' + location.host + '/');
|
||||
topInnerHTML = audio.innerHTML.replace(
|
||||
'src="',
|
||||
'src="http://127.0.0.1:7657/i2psnark/' + location.host + '/'
|
||||
);
|
||||
audio.innerHTML = topInnerHTML + innerHTML;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch{
|
||||
};
|
||||
} catch {};
|
||||
}
|
||||
}
|
||||
return Promise.resolve({content: response});
|
||||
return Promise.resolve({ content: response });
|
||||
});
|
||||
|
256
scrub.js
256
scrub.js
@ -27,7 +27,7 @@ var contextScrub = async function(requestDetails) {
|
||||
}
|
||||
}
|
||||
return {
|
||||
requestHeaders: requestDetails.requestHeaders
|
||||
requestHeaders: requestDetails.requestHeaders,
|
||||
};
|
||||
} else if (context.name == routerpref) {
|
||||
if (i2pHost(requestDetails.url)) {
|
||||
@ -39,7 +39,7 @@ var contextScrub = async function(requestDetails) {
|
||||
}
|
||||
}
|
||||
return {
|
||||
requestHeaders: requestDetails.requestHeaders
|
||||
requestHeaders: requestDetails.requestHeaders,
|
||||
};
|
||||
}
|
||||
};
|
||||
@ -91,25 +91,25 @@ var contextScrub = async function(requestDetails) {
|
||||
var notMyContextNotMyProblem = async function() {
|
||||
var contexts = await browser.contextualIdentities.query({});
|
||||
var context1 = await browser.contextualIdentities.query({
|
||||
name: titlepref
|
||||
name: titlepref,
|
||||
});
|
||||
var context2 = await browser.contextualIdentities.query({
|
||||
name: routerpref
|
||||
name: routerpref,
|
||||
});
|
||||
var context3 = await browser.contextualIdentities.query({
|
||||
name: mailpref
|
||||
name: mailpref,
|
||||
});
|
||||
var context4 = await browser.contextualIdentities.query({
|
||||
name: torrentpref
|
||||
name: torrentpref,
|
||||
});
|
||||
var context5 = await browser.contextualIdentities.query({
|
||||
name: tunnelpref
|
||||
name: tunnelpref,
|
||||
});
|
||||
var context6 = await browser.contextualIdentities.query({
|
||||
name: ircpref
|
||||
name: ircpref,
|
||||
});
|
||||
var context7 = await browser.contextualIdentities.query({
|
||||
name: muwirepref
|
||||
name: muwirepref,
|
||||
});
|
||||
var othercontexts = [];
|
||||
console.log('Contexts:', contexts);
|
||||
@ -145,7 +145,7 @@ var contextSetup = function(requestDetails) {
|
||||
var i2pTabFind = async function(tabId) {
|
||||
try {
|
||||
var context = await browser.contextualIdentities.query({
|
||||
name: titlepref
|
||||
name: titlepref,
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
function Create() {
|
||||
@ -159,7 +159,7 @@ var contextSetup = function(requestDetails) {
|
||||
}
|
||||
browser.pageAction.setPopup({
|
||||
tabId: tabId.id,
|
||||
popup: 'security.html'
|
||||
popup: 'security.html',
|
||||
});
|
||||
browser.pageAction.show(tabId.id);
|
||||
}
|
||||
@ -168,7 +168,7 @@ var contextSetup = function(requestDetails) {
|
||||
var created = browser.tabs.create({
|
||||
active: true,
|
||||
cookieStoreId: context[0].cookieStoreId,
|
||||
url: requestDetails.url
|
||||
url: requestDetails.url,
|
||||
});
|
||||
created.then(onCreated, onContextError);
|
||||
}
|
||||
@ -183,7 +183,7 @@ var contextSetup = function(requestDetails) {
|
||||
var routerTabFind = async function(tabId) {
|
||||
try {
|
||||
var context = await browser.contextualIdentities.query({
|
||||
name: routerpref
|
||||
name: routerpref,
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
function Create() {
|
||||
@ -194,7 +194,7 @@ var contextSetup = function(requestDetails) {
|
||||
console.log('in favor of', tab.id);
|
||||
console.log('with context', tab.cookieStoreId);
|
||||
browser.tabs.remove(tabId.id);
|
||||
browser.tabs.move(tab.id, {index: 0});
|
||||
browser.tabs.move(tab.id, { index: 0 });
|
||||
}
|
||||
for (index = 0; index < tabs.length; index++) {
|
||||
if (index != tabs.length - 1)
|
||||
@ -202,7 +202,7 @@ var contextSetup = function(requestDetails) {
|
||||
}
|
||||
}
|
||||
var pins = browser.tabs.query({
|
||||
cookieStoreId: context[0].cookieStoreId
|
||||
cookieStoreId: context[0].cookieStoreId,
|
||||
});
|
||||
pins.then(closeOldTab, onError);
|
||||
}
|
||||
@ -215,7 +215,7 @@ var contextSetup = function(requestDetails) {
|
||||
active: true,
|
||||
pinned: true,
|
||||
cookieStoreId: context[0].cookieStoreId,
|
||||
url: requestDetails.url
|
||||
url: requestDetails.url,
|
||||
});
|
||||
created.then(onCreated, onContextError);
|
||||
}
|
||||
@ -230,7 +230,7 @@ var contextSetup = function(requestDetails) {
|
||||
var i2ptunnelTabFind = async function(tabId) {
|
||||
try {
|
||||
var context = await browser.contextualIdentities.query({
|
||||
name: tunnelpref
|
||||
name: tunnelpref,
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
function Create() {
|
||||
@ -241,7 +241,7 @@ var contextSetup = function(requestDetails) {
|
||||
console.log('in favor of', tab.id);
|
||||
console.log('with context', tab.cookieStoreId);
|
||||
browser.tabs.remove(tabId.id);
|
||||
browser.tabs.move(tab.id, {index: 1});
|
||||
browser.tabs.move(tab.id, { index: 1 });
|
||||
}
|
||||
for (index = 0; index < tabs.length; index++) {
|
||||
if (index != tabs.length - 1)
|
||||
@ -249,7 +249,7 @@ var contextSetup = function(requestDetails) {
|
||||
}
|
||||
}
|
||||
var pins = browser.tabs.query({
|
||||
cookieStoreId: context[0].cookieStoreId
|
||||
cookieStoreId: context[0].cookieStoreId,
|
||||
});
|
||||
pins.then(closeOldTab, onError);
|
||||
}
|
||||
@ -262,7 +262,7 @@ var contextSetup = function(requestDetails) {
|
||||
active: true,
|
||||
pinned: true,
|
||||
cookieStoreId: context[0].cookieStoreId,
|
||||
url: requestDetails.url
|
||||
url: requestDetails.url,
|
||||
});
|
||||
created.then(onCreated, onContextError);
|
||||
}
|
||||
@ -277,16 +277,16 @@ var contextSetup = function(requestDetails) {
|
||||
var snarkTabFind = async function(tabId) {
|
||||
try {
|
||||
var context = await browser.contextualIdentities.query({
|
||||
name: torrentpref
|
||||
name: torrentpref,
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
var exemptContext = await browser.contextualIdentities.query({
|
||||
name: titlepref
|
||||
name: titlepref,
|
||||
});
|
||||
let tmp = new URL(tabId.url);
|
||||
console.log('tabid host', tmp.host);
|
||||
if (!requestDetails.url.includes(tmp.host)) {
|
||||
// if (tabId.cookieStoreId != exemptContext[0].cookieStoreId){
|
||||
// if (tabId.cookieStoreId != exemptContext[0].cookieStoreId){
|
||||
function Create() {
|
||||
function onCreated(tab) {
|
||||
function closeOldTab(tabs) {
|
||||
@ -295,7 +295,7 @@ var contextSetup = function(requestDetails) {
|
||||
console.log('in favor of', tab.id);
|
||||
console.log('with context', tab.cookieStoreId);
|
||||
browser.tabs.remove(tabId.id);
|
||||
browser.tabs.move(tab.id, {index: 2});
|
||||
browser.tabs.move(tab.id, { index: 2 });
|
||||
}
|
||||
for (index = 0; index < tabs.length; index++) {
|
||||
if (index != tabs.length - 1)
|
||||
@ -303,7 +303,7 @@ var contextSetup = function(requestDetails) {
|
||||
}
|
||||
}
|
||||
var pins = browser.tabs.query({
|
||||
cookieStoreId: context[0].cookieStoreId
|
||||
cookieStoreId: context[0].cookieStoreId,
|
||||
});
|
||||
pins.then(closeOldTab, onError);
|
||||
}
|
||||
@ -316,7 +316,7 @@ var contextSetup = function(requestDetails) {
|
||||
active: true,
|
||||
pinned: true,
|
||||
cookieStoreId: context[0].cookieStoreId,
|
||||
url: requestDetails.url
|
||||
url: requestDetails.url,
|
||||
});
|
||||
created.then(onCreated, onContextError);
|
||||
}
|
||||
@ -332,7 +332,7 @@ var contextSetup = function(requestDetails) {
|
||||
var muwireTabFind = async function(tabId) {
|
||||
try {
|
||||
var context = await browser.contextualIdentities.query({
|
||||
name: muwirepref
|
||||
name: muwirepref,
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
function Create() {
|
||||
@ -343,7 +343,7 @@ var contextSetup = function(requestDetails) {
|
||||
console.log('in favor of', tab.id);
|
||||
console.log('with context', tab.cookieStoreId);
|
||||
browser.tabs.remove(tabId.id);
|
||||
browser.tabs.move(tab.id, {index: 4});
|
||||
browser.tabs.move(tab.id, { index: 4 });
|
||||
}
|
||||
for (index = 0; index < tabs.length; index++) {
|
||||
if (index != tabs.length - 1)
|
||||
@ -351,7 +351,7 @@ var contextSetup = function(requestDetails) {
|
||||
}
|
||||
}
|
||||
var pins = browser.tabs.query({
|
||||
cookieStoreId: context[0].cookieStoreId
|
||||
cookieStoreId: context[0].cookieStoreId,
|
||||
});
|
||||
pins.then(closeOldTab, onError);
|
||||
}
|
||||
@ -364,7 +364,7 @@ var contextSetup = function(requestDetails) {
|
||||
active: true,
|
||||
pinned: true,
|
||||
cookieStoreId: context[0].cookieStoreId,
|
||||
url: requestDetails.url
|
||||
url: requestDetails.url,
|
||||
});
|
||||
created.then(onCreated, onContextError);
|
||||
}
|
||||
@ -379,7 +379,7 @@ var contextSetup = function(requestDetails) {
|
||||
var mailTabFind = async function(tabId) {
|
||||
try {
|
||||
var context = await browser.contextualIdentities.query({
|
||||
name: mailpref
|
||||
name: mailpref,
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
function Create() {
|
||||
@ -390,7 +390,7 @@ var contextSetup = function(requestDetails) {
|
||||
console.log('in favor of', tab.id);
|
||||
console.log('with context', tab.cookieStoreId);
|
||||
browser.tabs.remove(tabId.id);
|
||||
browser.tabs.move(tab.id, {index: 3});
|
||||
browser.tabs.move(tab.id, { index: 3 });
|
||||
}
|
||||
for (index = 0; index < tabs.length; index++) {
|
||||
if (index != tabs.length - 1)
|
||||
@ -398,7 +398,7 @@ var contextSetup = function(requestDetails) {
|
||||
}
|
||||
}
|
||||
var pins = browser.tabs.query({
|
||||
cookieStoreId: context[0].cookieStoreId
|
||||
cookieStoreId: context[0].cookieStoreId,
|
||||
});
|
||||
pins.then(closeOldTab, onError);
|
||||
}
|
||||
@ -411,7 +411,7 @@ var contextSetup = function(requestDetails) {
|
||||
active: true,
|
||||
pinned: true,
|
||||
cookieStoreId: context[0].cookieStoreId,
|
||||
url: requestDetails.url
|
||||
url: requestDetails.url,
|
||||
});
|
||||
created.then(onCreated, onContextError);
|
||||
}
|
||||
@ -426,7 +426,7 @@ var contextSetup = function(requestDetails) {
|
||||
var ircTabFind = async function(tabId) {
|
||||
try {
|
||||
var context = await browser.contextualIdentities.query({
|
||||
name: ircpref
|
||||
name: ircpref,
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
if (requestDetails.url.includes(':7669')) {
|
||||
@ -445,7 +445,7 @@ var contextSetup = function(requestDetails) {
|
||||
}
|
||||
}
|
||||
var pins = browser.tabs.query({
|
||||
cookieStoreId: context[0].cookieStoreId
|
||||
cookieStoreId: context[0].cookieStoreId,
|
||||
});
|
||||
pins.then(closeOldTab, onError);
|
||||
}
|
||||
@ -453,7 +453,7 @@ var contextSetup = function(requestDetails) {
|
||||
active: true,
|
||||
pinned: true,
|
||||
cookieStoreId: context[0].cookieStoreId,
|
||||
url: requestDetails.url
|
||||
url: requestDetails.url,
|
||||
});
|
||||
created.then(onCreated, onContextError);
|
||||
}
|
||||
@ -461,7 +461,6 @@ var contextSetup = function(requestDetails) {
|
||||
gettab.then(Create, onContextError);
|
||||
return tabId;
|
||||
}
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('(isolate)Context Error', error);
|
||||
@ -473,10 +472,10 @@ var contextSetup = function(requestDetails) {
|
||||
}
|
||||
try {
|
||||
var anoncontext = await browser.contextualIdentities.query({
|
||||
name: titlepref
|
||||
name: titlepref,
|
||||
});
|
||||
var irccontext = await browser.contextualIdentities.query({
|
||||
name: ircpref
|
||||
name: ircpref,
|
||||
});
|
||||
var othercontexts = await notMyContextNotMyProblem();
|
||||
var nmp = false;
|
||||
@ -529,7 +528,7 @@ var contextSetup = function(requestDetails) {
|
||||
var created = browser.tabs.create({
|
||||
active: true,
|
||||
cookieStoreId: 'firefox-default',
|
||||
url: requestDetails.url
|
||||
url: requestDetails.url,
|
||||
});
|
||||
created.then(onCreated, onContextError);
|
||||
}
|
||||
@ -557,7 +556,7 @@ var contextSetup = function(requestDetails) {
|
||||
setcookie = browser.cookies.set({
|
||||
firstPartyDomain: i2pHostName(requestDetails.url),
|
||||
url: requestDetails.url,
|
||||
secure: true
|
||||
secure: true,
|
||||
});
|
||||
setcookie.then(onContextGotLog, onContextError);
|
||||
return requestDetails;
|
||||
@ -569,7 +568,7 @@ var contextSetup = function(requestDetails) {
|
||||
var setcookie = browser.cookies.set({
|
||||
firstPartyDomain: i2pHostName(requestDetails.url),
|
||||
url: requestDetails.url,
|
||||
secure: true
|
||||
secure: true,
|
||||
});
|
||||
setcookie.then(onContextGotLog, onContextError);
|
||||
var i2ptab = tab.then(i2pTabFind, onContextError);
|
||||
@ -618,24 +617,36 @@ var coolheadersSetup = function(e) {
|
||||
for (i = 0; i < e.responseHeaders.length; i++) {
|
||||
let header = e.responseHeaders[i];
|
||||
if (e.url.startsWith('https')) {
|
||||
if (header.name.toUpperCase() === 'I2P-LOCATION' || header.name.toUpperCase() === 'X-I2P-LOCATION') {
|
||||
if (
|
||||
header.name.toUpperCase() === 'I2P-LOCATION' ||
|
||||
header.name.toUpperCase() === 'X-I2P-LOCATION'
|
||||
) {
|
||||
browser.pageAction.setPopup({
|
||||
tabId: e.tabId,
|
||||
popup: 'location.html'
|
||||
popup: 'location.html',
|
||||
});
|
||||
browser.pageAction.setIcon({
|
||||
path: 'icons/i2plogo.png',
|
||||
tabId: e.tabId,
|
||||
});
|
||||
browser.pageAction.setIcon({path: 'icons/i2plogo.png', tabId: e.tabId});
|
||||
browser.pageAction.setTitle({
|
||||
tabId: e.tabId,
|
||||
title: header.value
|
||||
title: header.value,
|
||||
});
|
||||
browser.pageAction.show(e.tabId);
|
||||
break;
|
||||
}
|
||||
if (header.name.toUpperCase() === 'I2P-TORRENTLOCATION' || header.name.toUpperCase() === 'X-I2P-TORRENTLOCATION') {
|
||||
if (
|
||||
header.name.toUpperCase() === 'I2P-TORRENTLOCATION' ||
|
||||
header.name.toUpperCase() === 'X-I2P-TORRENTLOCATION'
|
||||
) {
|
||||
var imgs = document.getElementsByTagName('img');
|
||||
for (let img of imgs) {
|
||||
if (tmpsrc.host == location.host) {
|
||||
img.src = 'http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;
|
||||
img.src =
|
||||
'http://127.0.0.1:7657/i2psnark/' +
|
||||
tmpsrc.host +
|
||||
tmpsrc.pathname;
|
||||
img.onerror = function() {
|
||||
img.src = tmpsrc;
|
||||
};
|
||||
@ -647,7 +658,10 @@ var coolheadersSetup = function(e) {
|
||||
if (tmpsrc.host == location.host) {
|
||||
if (!video.innerHTML.includes('127.0.0.1')) {
|
||||
innerHTML = video.innerHTML;
|
||||
topInnerHTML = video.innerHTML.replace('src=\"', 'src=\"http://127.0.0.1:7657/i2psnark/' + location.host + '/');
|
||||
topInnerHTML = video.innerHTML.replace(
|
||||
'src="',
|
||||
'src="http://127.0.0.1:7657/i2psnark/' + location.host + '/'
|
||||
);
|
||||
video.innerHTML = topInnerHTML + innerHTML;
|
||||
}
|
||||
}
|
||||
@ -658,29 +672,41 @@ var coolheadersSetup = function(e) {
|
||||
if (tmpsrc.host == location.host) {
|
||||
if (!audio.innerHTML.includes('127.0.0.1')) {
|
||||
innerHTML = audio.innerHTML;
|
||||
topInnerHTML = audio.innerHTML.replace('src=\"', 'src=\"http://127.0.0.1:7657/i2psnark/' + location.host + '/');
|
||||
topInnerHTML = audio.innerHTML.replace(
|
||||
'src="',
|
||||
'src="http://127.0.0.1:7657/i2psnark/' + location.host + '/'
|
||||
);
|
||||
audio.innerHTML = topInnerHTML + innerHTML;
|
||||
}
|
||||
}
|
||||
}
|
||||
browser.pageAction.setPopup({
|
||||
tabId: tabId.id,
|
||||
popup: 'torrent.html'
|
||||
popup: 'torrent.html',
|
||||
});
|
||||
browser.pageAction.setIcon({
|
||||
path: 'icons/i2plogo.png',
|
||||
tabId: e.tabId,
|
||||
});
|
||||
browser.pageAction.setIcon({path: 'icons/i2plogo.png', tabId: e.tabId});
|
||||
browser.pageAction.setTitle({
|
||||
tabId: e.tabId,
|
||||
title: header.value
|
||||
title: header.value,
|
||||
});
|
||||
browser.pageAction.show(e.tabId);
|
||||
break;
|
||||
}
|
||||
}else {
|
||||
if (header.name.toUpperCase() === 'I2P-TORRENTLOCATION' || header.name.toUpperCase() === 'X-I2P-TORRENTLOCATION') {
|
||||
} else {
|
||||
if (
|
||||
header.name.toUpperCase() === 'I2P-TORRENTLOCATION' ||
|
||||
header.name.toUpperCase() === 'X-I2P-TORRENTLOCATION'
|
||||
) {
|
||||
var imgs = document.getElementsByTagName('img');
|
||||
for (let img of imgs) {
|
||||
if (tmpsrc.host == location.host) {
|
||||
img.src = 'http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;
|
||||
img.src =
|
||||
'http://127.0.0.1:7657/i2psnark/' +
|
||||
tmpsrc.host +
|
||||
tmpsrc.pathname;
|
||||
img.onerror = function() {
|
||||
img.src = tmpsrc;
|
||||
};
|
||||
@ -692,7 +718,10 @@ var coolheadersSetup = function(e) {
|
||||
if (tmpsrc.host == location.host) {
|
||||
if (!video.innerHTML.includes('127.0.0.1')) {
|
||||
innerHTML = video.innerHTML;
|
||||
topInnerHTML = video.innerHTML.replace('src=\"', 'src=\"http://127.0.0.1:7657/i2psnark/' + location.host + '/');
|
||||
topInnerHTML = video.innerHTML.replace(
|
||||
'src="',
|
||||
'src="http://127.0.0.1:7657/i2psnark/' + location.host + '/'
|
||||
);
|
||||
video.innerHTML = topInnerHTML + innerHTML;
|
||||
}
|
||||
}
|
||||
@ -703,71 +732,87 @@ var coolheadersSetup = function(e) {
|
||||
if (tmpsrc.host == location.host) {
|
||||
if (!audio.innerHTML.includes('127.0.0.1')) {
|
||||
innerHTML = audio.innerHTML;
|
||||
topInnerHTML = audio.innerHTML.replace('src=\"', 'src=\"http://127.0.0.1:7657/i2psnark/' + location.host + '/');
|
||||
topInnerHTML = audio.innerHTML.replace(
|
||||
'src="',
|
||||
'src="http://127.0.0.1:7657/i2psnark/' + location.host + '/'
|
||||
);
|
||||
audio.innerHTML = topInnerHTML + innerHTML;
|
||||
}
|
||||
}
|
||||
}
|
||||
browser.pageAction.setPopup({
|
||||
tabId: tabId.id,
|
||||
popup: 'torrent.html'
|
||||
popup: 'torrent.html',
|
||||
});
|
||||
browser.pageAction.setIcon({
|
||||
path: 'icons/i2plogo.png',
|
||||
tabId: e.tabId,
|
||||
});
|
||||
browser.pageAction.setIcon({path: 'icons/i2plogo.png', tabId: e.tabId});
|
||||
browser.pageAction.setTitle({
|
||||
tabId: e.tabId,
|
||||
title: header.value
|
||||
title: header.value,
|
||||
});
|
||||
browser.pageAction.show(e.tabId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
resolve({responseHeaders: e.responseHeaders});
|
||||
resolve({ responseHeaders: e.responseHeaders });
|
||||
}, 2000);
|
||||
});
|
||||
return asyncSetPageAction;
|
||||
}
|
||||
};
|
||||
|
||||
function getClearTab(tobj) {
|
||||
function getTabURL(tab) {
|
||||
if (tab.url.startsWith("https")){
|
||||
browser.tabs.sendMessage( tab.id, {'req':'i2p-location'}).then( response => {
|
||||
if (response.content.toUpperCase() != "NO-ALT-LOCATION"){
|
||||
browser.pageAction.setPopup({
|
||||
tabId: tab.id,
|
||||
popup: 'location.html'
|
||||
});
|
||||
browser.pageAction.setIcon({path: 'icons/i2plogo.png', tabId: tab.id});
|
||||
browser.pageAction.setTitle({
|
||||
tabId: tab.id,
|
||||
title: response.content
|
||||
});
|
||||
browser.pageAction.show(tab.id);
|
||||
}
|
||||
});
|
||||
console.log("(pageaction)", tab.id, tab.url)
|
||||
if (tab.url.startsWith("https")) {
|
||||
browser.tabs
|
||||
.sendMessage(tab.id, { req: "i2p-location" })
|
||||
.then((response) => {
|
||||
if (response.content.toUpperCase() != "NO-ALT-LOCATION") {
|
||||
browser.pageAction.setPopup({
|
||||
tabId: tab.id,
|
||||
popup: "location.html",
|
||||
});
|
||||
browser.pageAction.setIcon({
|
||||
path: "icons/i2plogo.png",
|
||||
tabId: tab.id,
|
||||
});
|
||||
browser.pageAction.setTitle({
|
||||
tabId: tab.id,
|
||||
title: response.content,
|
||||
});
|
||||
browser.pageAction.show(tab.id);
|
||||
}
|
||||
});
|
||||
console.log("(pageaction)", tab.id, tab.url);
|
||||
} else {
|
||||
browser.tabs.sendMessage( tab.id, {'req':'i2p-torrentlocation'}).then( response => {
|
||||
if (response.content.toUpperCase() != "NO-ALT-LOCATION"){
|
||||
browser.pageAction.setPopup({
|
||||
tabId: tab.id,
|
||||
popup: 'torrent.html'
|
||||
});
|
||||
browser.pageAction.setIcon({path: 'icons/i2plogo.png', tabId: tab.id});
|
||||
browser.pageAction.setTitle({
|
||||
tabId: tab.id,
|
||||
title: response.content
|
||||
});
|
||||
browser.pageAction.show(tab.id);
|
||||
}
|
||||
});
|
||||
console.log("(pageaction)", tab.id, tab.url)
|
||||
browser.tabs
|
||||
.sendMessage(tab.id, { req: "i2p-torrentlocation" })
|
||||
.then((response) => {
|
||||
if (response.content.toUpperCase() != "NO-ALT-LOCATION") {
|
||||
browser.pageAction.setPopup({
|
||||
tabId: tab.id,
|
||||
popup: "torrent.html",
|
||||
});
|
||||
browser.pageAction.setIcon({
|
||||
path: "icons/i2plogo.png",
|
||||
tabId: tab.id,
|
||||
});
|
||||
browser.pageAction.setTitle({
|
||||
tabId: tab.id,
|
||||
title: response.content,
|
||||
});
|
||||
browser.pageAction.show(tab.id);
|
||||
}
|
||||
});
|
||||
console.log("(pageaction)", tab.id, tab.url);
|
||||
}
|
||||
}
|
||||
if (typeof(tobj) == "number"){
|
||||
browser.tabs.get(tobj).then(getTabURL, onError)
|
||||
}else{
|
||||
browser.tabs.get(tobj.tabId).then(getTabURL, onError)
|
||||
if (typeof tobj == "number") {
|
||||
browser.tabs.get(tobj).then(getTabURL, onError);
|
||||
} else {
|
||||
browser.tabs.get(tobj.tabId).then(getTabURL, onError);
|
||||
}
|
||||
}
|
||||
|
||||
@ -776,7 +821,7 @@ browser.tabs.onUpdated.addListener(getClearTab);
|
||||
|
||||
function reloadTabs(tabs) {
|
||||
for (let tab of tabs) {
|
||||
browser.tabs.reload(tab.id)
|
||||
browser.tabs.reload(tab.id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -787,23 +832,22 @@ function reloadError(error) {
|
||||
let querying = browser.tabs.query({});
|
||||
querying.then(reloadTabs, onError);
|
||||
|
||||
|
||||
// Listen for onHeaderReceived for the target page.
|
||||
// Set "blocking" and "responseHeaders".
|
||||
browser.webRequest.onHeadersReceived.addListener(
|
||||
coolheadersSetup,
|
||||
{urls: ['<all_urls>']},
|
||||
{ urls: ["<all_urls>"] },
|
||||
["blocking", "responseHeaders"]
|
||||
);
|
||||
|
||||
browser.webRequest.onBeforeRequest.addListener(
|
||||
contextSetup,
|
||||
{ urls: ['<all_urls>'] },
|
||||
['blocking']
|
||||
{ urls: ["<all_urls>"] },
|
||||
["blocking"]
|
||||
);
|
||||
|
||||
browser.webRequest.onBeforeSendHeaders.addListener(
|
||||
contextScrub,
|
||||
{ urls: ['<all_urls>'] },
|
||||
['blocking', 'requestHeaders']
|
||||
{ urls: ["<all_urls>"] },
|
||||
["blocking", "requestHeaders"]
|
||||
);
|
||||
|
@ -1,15 +1,14 @@
|
||||
|
||||
function gotCurrent(tab) {
|
||||
function gotTitle(title) {
|
||||
let addr = title;
|
||||
document.getElementById('TypeInfo').innerHTML = '<div class=\"AddressInfo\"><a href=\"' + addr + '\">' + addr + '</a></div>';
|
||||
document.getElementById('TypeInfo').innerHTML =
|
||||
'<div class="AddressInfo"><a href="' + addr + '">' + addr + '</a></div>';
|
||||
}
|
||||
console.log(tab);
|
||||
var gettingTitle = browser.pageAction.getTitle({
|
||||
tabId: tab[0].id
|
||||
tabId: tab[0].id,
|
||||
});
|
||||
gettingTitle.then(gotTitle);
|
||||
|
||||
}
|
||||
|
||||
function tabError(error) {
|
||||
|
@ -21,7 +21,7 @@ setupExtractor();
|
||||
|
||||
function extractSession(requestDetails) {
|
||||
const hdr = requestDetails.requestHeaders.filter(
|
||||
x => x.name.toLowerCase() === "x-transmission-session-id"
|
||||
(x) => x.name.toLowerCase() === "x-transmission-session-id"
|
||||
)[0];
|
||||
if (!hdr) {
|
||||
return;
|
||||
@ -58,21 +58,21 @@ function addUrl(torrentUrl, downloadDir) {
|
||||
console.log("Downloading torrent", torrentUrl);
|
||||
p = fetch(torrentUrl, {
|
||||
method: "GET",
|
||||
credentials: "include"
|
||||
credentials: "include",
|
||||
})
|
||||
.then(resp => {
|
||||
.then((resp) => {
|
||||
if (resp.ok) {
|
||||
return resp.blob();
|
||||
}
|
||||
throw new Error("Could not download torrent");
|
||||
})
|
||||
.then(blobToBase64)
|
||||
.then(b64 => {
|
||||
.then((b64) => {
|
||||
params.metainfo = b64;
|
||||
return rpcCall("torrent-add", params);
|
||||
});
|
||||
}
|
||||
return p.then(x => {
|
||||
return p.then((x) => {
|
||||
updateBadge();
|
||||
return x;
|
||||
});
|
||||
@ -85,7 +85,7 @@ function handleUrl(requestDetails) {
|
||||
decodeURIComponent(
|
||||
requestDetails.url.replace("http://transmitter.web-extension/", "")
|
||||
)
|
||||
).then(x => {
|
||||
).then((x) => {
|
||||
return browser.storage.local.get("server").then(({ server }) => {
|
||||
return { redirectUrl: server.base_url + "web/" };
|
||||
});
|
||||
@ -107,19 +107,19 @@ function createContextMenu() {
|
||||
browser.contextMenus.create({
|
||||
id: "transmitter-add",
|
||||
title: "Download with Transmission remote",
|
||||
contexts: ["link"]
|
||||
contexts: ["link"],
|
||||
});
|
||||
} else {
|
||||
browser.contextMenus.create({
|
||||
id: "transmitter-add",
|
||||
title: "Download to Default location",
|
||||
contexts: ["link"]
|
||||
contexts: ["link"],
|
||||
});
|
||||
server.locations.forEach(location => {
|
||||
server.locations.forEach((location) => {
|
||||
browser.contextMenus.create({
|
||||
id: "transmitter-add-loc-" + location.index,
|
||||
title: "Download to " + location.name,
|
||||
contexts: ["link"]
|
||||
contexts: ["link"],
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -152,42 +152,42 @@ function updateBadge() {
|
||||
) {
|
||||
return;
|
||||
}
|
||||
return rpcCall("session-stats", {}).then(response => {
|
||||
return rpcCall("session-stats", {}).then((response) => {
|
||||
const args = response.arguments; // lol the name 'arguments' means destructuring in strict mode is impossible
|
||||
switch (server.badge) {
|
||||
case "num":
|
||||
browser.browserAction.setBadgeBackgroundColor({ color: "gray" });
|
||||
browser.browserAction.setBadgeText({
|
||||
text: "" + args.activeTorrentCount
|
||||
text: "" + args.activeTorrentCount,
|
||||
});
|
||||
break;
|
||||
case "dl":
|
||||
browser.browserAction.setBadgeBackgroundColor({ color: "green" });
|
||||
browser.browserAction.setBadgeText({
|
||||
text: formatSpeed(args.downloadSpeed)
|
||||
text: formatSpeed(args.downloadSpeed),
|
||||
});
|
||||
break;
|
||||
case "ul":
|
||||
browser.browserAction.setBadgeBackgroundColor({ color: "blue" });
|
||||
browser.browserAction.setBadgeText({
|
||||
text: formatSpeed(args.uploadSpeed)
|
||||
text: formatSpeed(args.uploadSpeed),
|
||||
});
|
||||
break;
|
||||
case "auto":
|
||||
if (args.downloadSpeed > 0) {
|
||||
browser.browserAction.setBadgeBackgroundColor({ color: "green" });
|
||||
browser.browserAction.setBadgeText({
|
||||
text: formatSpeed(args.downloadSpeed)
|
||||
text: formatSpeed(args.downloadSpeed),
|
||||
});
|
||||
} else if (args.uploadSpeed > 0) {
|
||||
browser.browserAction.setBadgeBackgroundColor({ color: "blue" });
|
||||
browser.browserAction.setBadgeText({
|
||||
text: formatSpeed(args.uploadSpeed)
|
||||
text: formatSpeed(args.uploadSpeed),
|
||||
});
|
||||
} else {
|
||||
browser.browserAction.setBadgeBackgroundColor({ color: "gray" });
|
||||
browser.browserAction.setBadgeText({
|
||||
text: "" + args.activeTorrentCount
|
||||
text: "" + args.activeTorrentCount,
|
||||
});
|
||||
}
|
||||
break;
|
||||
@ -196,20 +196,20 @@ function updateBadge() {
|
||||
});
|
||||
}
|
||||
|
||||
browser.alarms.onAlarm.addListener(alarm => {
|
||||
browser.alarms.onAlarm.addListener((alarm) => {
|
||||
if (alarm.name === "transmitter-badge-update") {
|
||||
return updateBadge();
|
||||
}
|
||||
});
|
||||
|
||||
function setupBadge() {
|
||||
browser.alarms.clear("transmitter-badge-update").then(x => {
|
||||
browser.alarms.clear("transmitter-badge-update").then((x) => {
|
||||
browser.storage.local.get("server").then(({ server }) => {
|
||||
if (!server) {
|
||||
return;
|
||||
}
|
||||
browser.alarms.create("transmitter-badge-update", {
|
||||
periodInMinutes: parseInt(server.badge_interval || "1")
|
||||
periodInMinutes: parseInt(server.badge_interval || "1"),
|
||||
});
|
||||
updateBadge();
|
||||
});
|
||||
|
@ -6,7 +6,7 @@ function rpcCall(meth, args) {
|
||||
return browser.storage.local.get(function(server) {
|
||||
const myHeaders = {
|
||||
'Content-Type': 'application/json',
|
||||
'x-transmission-session-id': server.session
|
||||
'x-transmission-session-id': server.session,
|
||||
};
|
||||
//console.log("(torrent)", server.session)
|
||||
if (server.username !== '' || server.btrpcpass !== '') {
|
||||
@ -19,7 +19,7 @@ function rpcCall(meth, args) {
|
||||
method: 'POST',
|
||||
headers: myHeaders,
|
||||
body: JSON.stringify({ method: meth, arguments: args }),
|
||||
credentials: 'include' // allows HTTPS client certs!
|
||||
credentials: 'include', // allows HTTPS client certs!
|
||||
})
|
||||
.then(function(response) {
|
||||
const session = response.headers.get('x-transmission-session-id');
|
||||
|
@ -4,7 +4,7 @@ var TrpcCall = async function(meth, args) {
|
||||
const server = await browser.storage.local.get(null);
|
||||
const myHeaders = {
|
||||
'Content-Type': 'application/json',
|
||||
'x-transmission-session-id': server.session
|
||||
'x-transmission-session-id': server.session,
|
||||
};
|
||||
console.log('(torrent) session', server.session);
|
||||
if (server.username !== '' || server.btrpcpass !== '') {
|
||||
@ -16,7 +16,7 @@ var TrpcCall = async function(meth, args) {
|
||||
method: 'POST',
|
||||
headers: myHeaders,
|
||||
body: JSON.stringify({ method: meth, arguments: args }),
|
||||
credentials: 'include' // allows HTTPS client certs!
|
||||
credentials: 'include', // allows HTTPS client certs!
|
||||
});
|
||||
|
||||
/*.then(function(response) {
|
||||
@ -38,7 +38,7 @@ const torrentsPane = document.getElementById('torrents-pane');
|
||||
const configPane = document.getElementById('config-pane');
|
||||
|
||||
for (const opener of document.querySelectorAll('.config-opener')) {
|
||||
opener.addEventListener('click', e => {
|
||||
opener.addEventListener('click', (e) => {
|
||||
browser.runtime.openOptionsPage();
|
||||
});
|
||||
}
|
||||
@ -53,7 +53,13 @@ const torrentsList = document.getElementById("torrents-list");
|
||||
const torrentsTpl = document.getElementById("torrents-tpl");
|
||||
const torrentsError = document.getElementById("torrents-error");
|
||||
const getArgs = {
|
||||
fields: ["name", "percentDone", "rateDownload", "rateUpload", "queuePosition"]
|
||||
fields: [
|
||||
"name",
|
||||
"percentDone",
|
||||
"rateDownload",
|
||||
"rateUpload",
|
||||
"queuePosition",
|
||||
],
|
||||
};
|
||||
let cachedTorrents = [];
|
||||
|
||||
@ -90,7 +96,7 @@ function searchTorrents() {
|
||||
let newTorrents = cachedTorrents;
|
||||
const val = torrentsSearch.value.toLowerCase().trim();
|
||||
if (val.length > 0) {
|
||||
newTorrents = newTorrents.filter(x => x.name.toLowerCase().includes(val));
|
||||
newTorrents = newTorrents.filter((x) => x.name.toLowerCase().includes(val));
|
||||
}
|
||||
renderTorrents(newTorrents);
|
||||
}
|
||||
@ -99,16 +105,16 @@ torrentsSearch.addEventListener("keyup", searchTorrents);
|
||||
|
||||
function refreshTorrents(server) {
|
||||
console.log("(torrent) initiating", server);
|
||||
return TrpcCall("torrent-get", getArgs).then(function(response) {
|
||||
return TrpcCall("torrent-get", getArgs).then(function (response) {
|
||||
const session = response.headers.get("x-transmission-session-id");
|
||||
if (session) {
|
||||
browser.storage.local.get({}).then(function(storage) {
|
||||
browser.storage.local.get({}).then(function (storage) {
|
||||
storage.session = session;
|
||||
browser.storage.local.set(storage);
|
||||
});
|
||||
}
|
||||
let sponse = response.json();
|
||||
sponse.then(function(response) {
|
||||
sponse.then(function (response) {
|
||||
console.log("(torrent) refreshing", response);
|
||||
let newTorrents = response.arguments.torrents;
|
||||
newTorrents.sort((x, y) => y.queuePosition - x.queuePosition);
|
||||
@ -125,7 +131,7 @@ function refreshTorrents(server) {
|
||||
}
|
||||
|
||||
function refreshTorrentsLogErr(server) {
|
||||
return refreshTorrents(server).catch(err => {
|
||||
return refreshTorrents(server).catch((err) => {
|
||||
console.error(err);
|
||||
torrentsError.textContent = "Error: " + err.toString();
|
||||
});
|
||||
@ -138,12 +144,12 @@ function showTorrents(server) {
|
||||
opener.href = server.base_url + "web/";
|
||||
}
|
||||
console.log("(torrent) showing torrents");
|
||||
refreshTorrents(server).catch(_ => refreshTorrentsLogErr(server));
|
||||
refreshTorrents(server).catch((_) => refreshTorrentsLogErr(server));
|
||||
setInterval(() => refreshTorrentsLogErr(server), 2000);
|
||||
}
|
||||
|
||||
//let store =
|
||||
browser.storage.local.get(function(server) {
|
||||
browser.storage.local.get(function (server) {
|
||||
console.log("(torrent) querying storage", server);
|
||||
if (server && server.base_url && server.base_url !== "") {
|
||||
showTorrents(server);
|
||||
|
Reference in New Issue
Block a user