Verified Commit 19979172 authored by Marco Kellershoff's avatar Marco Kellershoff 🤸
Browse files

Initial import

parents
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_size = 8
indent_style = space
{
"env": {
"browser": true,
"es6": true
},
"extends": "eslint:recommended",
"globals": {
"chrome": true
},
"rules": {
"accessor-pairs": "error",
"array-bracket-newline": "error",
"array-bracket-spacing": [
"error",
"never"
],
"array-callback-return": "error",
"array-element-newline": "off",
"arrow-body-style": "error",
"arrow-parens": [
"error",
"as-needed",
{
"requireForBlockBody": true
}
],
"arrow-spacing": [
"error",
{
"after": true,
"before": true
}
],
"block-scoped-var": "error",
"block-spacing": "off",
"brace-style": "off",
"callback-return": "off",
"camelcase": "off",
"capitalized-comments": [
"error",
"never"
],
"class-methods-use-this": "error",
"comma-dangle": "off",
"comma-spacing": [
"error",
{
"after": true,
"before": false
}
],
"comma-style": [
"error",
"last"
],
"complexity": "error",
"computed-property-spacing": [
"error",
"never"
],
"consistent-return": "off",
"consistent-this": "off",
"curly": "off",
"default-case": "error",
"dot-location": [
"error",
"property"
],
"dot-notation": "error",
"eol-last": "error",
"eqeqeq": "error",
"for-direction": "error",
"func-call-spacing": "error",
"func-name-matching": "error",
"func-names": [
"error",
"never"
],
"func-style": "off",
"function-paren-newline": "error",
"generator-star-spacing": "error",
"getter-return": "error",
"global-require": "error",
"guard-for-in": "error",
"handle-callback-err": "error",
"id-blacklist": "error",
"id-length": "off",
"id-match": "error",
"implicit-arrow-linebreak": [
"error",
"beside"
],
"indent": "off",
"indent-legacy": "off",
"init-declarations": "off",
"jsx-quotes": "error",
"key-spacing": "error",
"keyword-spacing": [
"error",
{
"after": true,
"before": true
}
],
"line-comment-position": "error",
"linebreak-style": [
"error",
"unix"
],
"lines-around-comment": "error",
"lines-around-directive": "off",
"lines-between-class-members": "error",
"max-depth": "error",
"max-len": "off",
"max-lines": "off",
"max-nested-callbacks": "error",
"max-params": "error",
"max-statements": "off",
"max-statements-per-line": "off",
"multiline-comment-style": [
"error",
"separate-lines"
],
"new-parens": "error",
"newline-after-var": "off",
"newline-before-return": "off",
"newline-per-chained-call": "off",
"no-alert": "off",
"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-continue": "error",
"no-div-regex": "error",
"no-duplicate-imports": "error",
"no-else-return": "off",
"no-empty-function": "off",
"no-eq-null": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-extra-parens": "off",
"no-floating-decimal": "error",
"no-implicit-coercion": "error",
"no-implicit-globals": "error",
"no-implied-eval": "error",
"no-inline-comments": "off",
"no-invalid-this": "off",
"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": "off",
"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": "off",
"no-path-concat": "error",
"no-plusplus": "off",
"no-process-env": "error",
"no-process-exit": "error",
"no-proto": "error",
"no-prototype-builtins": "error",
"no-restricted-globals": "error",
"no-restricted-imports": "error",
"no-restricted-modules": "error",
"no-restricted-properties": "error",
"no-restricted-syntax": "error",
"no-return-assign": "off",
"no-return-await": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow": "error",
"no-shadow-restricted-names": "error",
"no-spaced-func": "error",
"no-sync": "error",
"no-tabs": "off",
"no-template-curly-in-string": "error",
"no-ternary": "off",
"no-throw-literal": "error",
"no-trailing-spaces": "off",
"no-undef-init": "error",
"no-undefined": "error",
"no-underscore-dangle": "off",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "error",
"no-unused-expressions": "error",
"no-use-before-define": "off",
"no-useless-call": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "off",
"no-useless-constructor": "error",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-var": "error",
"no-void": "error",
"no-warning-comments": "error",
"no-whitespace-before-property": "error",
"no-with": "error",
"nonblock-statement-body-position": [
"error",
"any"
],
"object-curly-newline": "error",
"object-curly-spacing": [
"error",
"always"
],
"object-property-newline": "error",
"object-shorthand": "off",
"one-var": "off",
"one-var-declaration-per-line": "off",
"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-numeric-literals": "error",
"prefer-promise-reject-errors": "error",
"prefer-reflect": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "off",
"quote-props": "off",
"quotes": "off",
"radix": [
"error",
"always"
],
"require-await": "error",
"require-jsdoc": "off",
"rest-spread-spacing": "error",
"semi": "off",
"semi-spacing": "error",
"semi-style": [
"error",
"last"
],
"sort-imports": "error",
"sort-keys": "off",
"sort-vars": "error",
"space-before-blocks": "off",
"space-before-function-paren": "off",
"space-in-parens": "off",
"space-infix-ops": "off",
"space-unary-ops": "error",
"spaced-comment": [
"error",
"always"
],
"strict": "error",
"switch-colon-spacing": "error",
"symbol-description": "error",
"template-curly-spacing": [
"error",
"never"
],
"template-tag-spacing": "error",
"unicode-bom": [
"error",
"never"
],
"valid-jsdoc": "error",
"vars-on-top": "error",
"wrap-regex": "error",
"yield-star-spacing": "error",
"yoda": [
"error",
"never"
]
}
}
src/manifest.json
config.json
tags
{
"extensionName": {
"message": "Gorilla Script- and Style-Loader",
"description": ""
},
"extensionDescription": {
"message": "Enables you to load Javascript and CSS into websites.",
"description": ""
}
}
(function() {
"use strict";
let injectionActive = false;
const setOption = function(key, value, cb) {
let typeOfCallback, val;
typeOfCallback = typeof cb;
if (typeOfCallback !== "function") {
cb = function() {};
}
val = {};
val[key] = value;
if (chrome && chrome.storage && chrome.storage.sync)
chrome.storage.sync.set(val, cb);
};
const getOption = function(key, defaultValue, cb) {
let typeOfKey;
typeOfKey = typeof key;
defaultValue =
typeof defaultValue === "undefined"
? null
: defaultValue;
if (typeOfKey === "string") {
key = [key];
}
chrome.storage.sync.get(key, function(res) {
if (res && res[key]) {
cb(res[key]);
} else {
cb(defaultValue);
}
});
};
const setIconBasedOnInjectionState = () => {
if (injectionActive === true) {
chrome.browserAction.setIcon({
path: "icons/icon-38-active.png"
});
} else {
chrome.browserAction.setIcon({
path: "icons/icon-38-inactive.png"
});
}
};
const toggleInjectionState = () => {
if (injectionActive === false) {
injectionActive = true;
setOption(
"injectionActive",
true,
setIconBasedOnInjectionState
);
} else {
injectionActive = false;
setOption(
"injectionActive",
false,
setIconBasedOnInjectionState
);
}
chrome.tabs.query(
{
active: true,
currentWindow: true
},
function(tabs) {
chrome.tabs.sendMessage(
tabs[0].id,
{ injectionActive: injectionActive },
() => {}
);
}
);
};
getOption("injectionActive", false, (res) => {
injectionActive = res;
setIconBasedOnInjectionState();
});
chrome.browserAction.onClicked.addListener(toggleInjectionState);
})();
(function() {
"use strict";
let alreadyInjected = false;
const getDataStoreKey = function(key, defaultValue, cb) {
let typeOfKey;
typeOfKey = typeof key;
defaultValue =
typeof defaultValue === "undefined"
? null
: defaultValue;
if (typeOfKey === "string") {
key = [key];
}
chrome.storage.sync.get(key, function(res) {
if (res && res[key]) {
cb(res[key]);
} else {
cb(defaultValue);
}
});
};
const createCSS = (url) => {
const l = document.createElement("link");
l.type = "text/css";
l.href = url;
document.head.appendChild(l);
};
const createScript = (url) => {
const s = document.createElement("script");
s.src = url;
document.head.appendChild(s);
};
const injectEverything = (injectionActive) => {
if (alreadyInjected) return;
if (injectionActive === false) return;
alreadyInjected = true;
getDataStoreKey("files", [], (files) => {
files.forEach((file) => {
if (file.type === "js") {
createScript(file.url);
}
if (file.type === "css") {
createCSS(file.url);
}
});
});
};
chrome.runtime.onMessage.addListener((msg) => {
injectEverything(msg.injectionActive);
});
getDataStoreKey("injectionActive", false, (injectionActive) => {
injectEverything(injectionActive);
});
})();
{
"manifest_version": 2,
"name": "Gorilla Script- and Style-Loader",
"version": "1.1.0",
"description": "Enables you to load Javascript and CSS into websites.",
"default_locale": "en",
"icons": {
"16": "icons/icon-16.png",
"32": "icons/icon-32.png",
"48": "icons/icon-48.png",
"96": "icons/icon-96.png"
},
"options_page": "options.html",
"permissions": [
"tabs",
"activeTab",
"storage"
],
"browser_action": {
"default_icon": "icons/icon-38.png"
},
"background": {
"scripts": ["background.js"]
},
"content_scripts": [
{
"matches": [
"http://*/*",
"https://*/*"
],
"js": [
"boot.js"
]
}
]
}
@font-face {
font-family: "monospace";
font-style: normal;
font-weight: 400;
}
html,
body {
background-color: #272b30;
color: #fff;
}
body {
font-size: 110%;
line-height: 1.8em;
}
a:link,
a:active,
a:visited {
color: #666;
}
.contentwrapper {
margin: 0 auto;
max-width: 100%;
padding-bottom: 42px;
width: 776px;
}
h1 {
border-bottom: 2px solid #f2cf66;
color: #de6a73;
}
h1 span {
color: #19cf85;
}
.hidden {
display: none;
}
.gorilla-heart {
color: #f00;
font-size: 170%;
padding: 5px;
}
.btn-file-add {
background-color: #19cf85;
}
.btn-file-remove {
background-color: #de6a73;
}
.input-file-url {
background-color: #222;
border: 5px solid #444;
border-radius: 10px;
color: #f2cf66;
font-size: 16px;
padding: 10px;
width: 350px;
}
.select-file-type {
background-color: #112233;
}
.select-file-type option:checked {
background-color: #051525;
}
kbd {
background-color: #f7f7f7;
border: 1px solid #ccc;
border-radius: 3px;
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 0 0 2px #fff inset;
color: #333;
display: inline-block;
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
line-height: 1.4;
margin: 0 0.1em;
padding: 0.1em 0.6em;
text-shadow: 0 1px 0 #fff;