├── icon.png
├── screenshots
└── demo.png
├── extensions
├── edge
│ ├── icon.png
│ ├── background.html
│ ├── manifest.json
│ ├── options.html
│ ├── options.js
│ ├── background.js
│ ├── main.js
│ ├── contentScriptsAPIBridge.js
│ ├── mustache.js
│ └── backgroundScriptsAPIBridge.js
├── chrome
│ ├── icon.png
│ ├── manifest.json
│ ├── options.html
│ ├── background.js
│ ├── options.js
│ ├── main.js
│ └── mustache.js
├── firefox
│ ├── icon.png
│ ├── data
│ │ ├── icon.png
│ │ └── main.js
│ ├── test
│ │ └── test-index.js
│ ├── index.js
│ └── package.json
├── packed
│ ├── make-github-greater.nex
│ ├── make-github-greater.xpi
│ ├── make-github-greater.edge.zip
│ └── make-github-greater.chrome.zip
└── make-github-greater.safariextension
│ ├── icon.png
│ ├── Settings.plist
│ ├── Info.plist
│ └── main.js
├── CHANGELOG.md
├── userscript
├── src
│ └── metadata.js
└── dist
│ └── make-github-greater.user.js
├── .gitignore
├── package.json
├── LICENSE
├── README.md
├── src
└── main.js
└── Gulpfile.js
/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Justineo/make-github-greater/HEAD/icon.png
--------------------------------------------------------------------------------
/screenshots/demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Justineo/make-github-greater/HEAD/screenshots/demo.png
--------------------------------------------------------------------------------
/extensions/edge/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Justineo/make-github-greater/HEAD/extensions/edge/icon.png
--------------------------------------------------------------------------------
/extensions/chrome/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Justineo/make-github-greater/HEAD/extensions/chrome/icon.png
--------------------------------------------------------------------------------
/extensions/firefox/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Justineo/make-github-greater/HEAD/extensions/firefox/icon.png
--------------------------------------------------------------------------------
/extensions/edge/background.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/extensions/firefox/data/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Justineo/make-github-greater/HEAD/extensions/firefox/data/icon.png
--------------------------------------------------------------------------------
/extensions/packed/make-github-greater.nex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Justineo/make-github-greater/HEAD/extensions/packed/make-github-greater.nex
--------------------------------------------------------------------------------
/extensions/packed/make-github-greater.xpi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Justineo/make-github-greater/HEAD/extensions/packed/make-github-greater.xpi
--------------------------------------------------------------------------------
/extensions/packed/make-github-greater.edge.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Justineo/make-github-greater/HEAD/extensions/packed/make-github-greater.edge.zip
--------------------------------------------------------------------------------
/extensions/packed/make-github-greater.chrome.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Justineo/make-github-greater/HEAD/extensions/packed/make-github-greater.chrome.zip
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | Changelog
2 | ---
3 |
4 | ## 1.0.1
5 | * Fill the color input with current saved color upon init.
6 |
7 | ## 1.0.0
8 |
9 | * First version.
10 |
--------------------------------------------------------------------------------
/extensions/make-github-greater.safariextension/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Justineo/make-github-greater/HEAD/extensions/make-github-greater.safariextension/icon.png
--------------------------------------------------------------------------------
/extensions/make-github-greater.safariextension/Settings.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/userscript/src/metadata.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name Make GitHub Greater
3 | // @namespace https://justineo.github.io/
4 | // @version {{version}}
5 | // @description Let's make GitHub greater.
6 | // @author Justineo(justice360@gmail.com)
7 | // @match https://github.com/*
8 | // @grant none
9 | // @updateURL https://justineo.github.io/make-github-greater/userscript/dist/make-github-greater.user.js
10 | // @icon https://justineo.github.io/make-github-greater/icon.png
11 | // ==/UserScript==
12 |
--------------------------------------------------------------------------------
/extensions/firefox/test/test-index.js:
--------------------------------------------------------------------------------
1 | var main = require("../");
2 |
3 | exports["test main"] = function(assert) {
4 | assert.pass("Unit test running!");
5 | };
6 |
7 | exports["test main async"] = function(assert, done) {
8 | assert.pass("async Unit test running!");
9 | done();
10 | };
11 |
12 | exports["test dummy"] = function(assert, done) {
13 | main.dummy("foo", function(text) {
14 | assert.ok((text === "foo"), "Is the text actually 'foo'");
15 | done();
16 | });
17 | };
18 |
19 | require("sdk/test").run(exports);
20 |
--------------------------------------------------------------------------------
/extensions/firefox/index.js:
--------------------------------------------------------------------------------
1 | let data = require('sdk/self').data;
2 | let prefs = require('sdk/simple-prefs').prefs;
3 | let pageMod = require('sdk/page-mod');
4 |
5 | let domains = prefs.domains || '';
6 | domains = domains.split(/[,\s]/)
7 | .map((domain) => [`http://${domain}/*`, `https://${domain}/*`])
8 | .reduce((prev, current) => prev.concat(current), [
9 | 'http://github.com/*', 'https://github.com/*'
10 | ]);
11 |
12 | pageMod.PageMod({
13 | include: domains,
14 | contentScriptFile: [
15 | data.url('kolor.js'),
16 | data.url('main.js')
17 | ],
18 | contentScriptOptions: {
19 | prefs: prefs
20 | }
21 | });
22 |
--------------------------------------------------------------------------------
/extensions/firefox/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "Make GitHub Greater",
3 | "name": "make-github-greater",
4 | "version": "1.0.1",
5 | "description": "Let's make GitHub greater.",
6 | "main": "index.js",
7 | "author": "Justineo",
8 | "homepage": "https://justineo.github.io/make-github-greater/",
9 | "permissions": {
10 | "multiprocess": true
11 | },
12 | "preferences": [
13 | {
14 | "name": "domains",
15 | "title": "Applicable Domains",
16 | "type": "string",
17 | "description": "Comma-separated domain list. (github.com is always included)"
18 | }
19 | ],
20 | "engines": {
21 | "firefox": ">=38.0a1",
22 | "fennec": ">=38.0a1"
23 | },
24 | "license": "MIT"
25 | }
--------------------------------------------------------------------------------
/extensions/chrome/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "manifest_version": 2,
3 | "name": "Make GitHub Greater",
4 | "description": "Let's make GitHub greater.",
5 | "version": "1.0.1",
6 | "icons": {
7 | "128": "icon.png"
8 | },
9 | "background": {
10 | "scripts": [
11 | "background.js"
12 | ],
13 | "persistent": false
14 | },
15 | "permissions": [
16 | "webNavigation",
17 | "tabs",
18 | "storage",
19 | "https://github.com/*"
20 | ],
21 | "optional_permissions": [
22 | ""
23 | ],
24 | "externally_connectable": {
25 | "matches": [
26 | "*://justineo.github.io/*"
27 | ]
28 | },
29 | "options_ui": {
30 | "page": "options.html",
31 | "chrome_style": true
32 | }
33 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 |
6 | # Runtime data
7 | pids
8 | *.pid
9 | *.seed
10 |
11 | # Directory for instrumented libs generated by jscoverage/JSCover
12 | lib-cov
13 |
14 | # Coverage directory used by tools like istanbul
15 | coverage
16 |
17 | # nyc test coverage
18 | .nyc_output
19 |
20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21 | .grunt
22 |
23 | # node-waf configuration
24 | .lock-wscript
25 |
26 | # Compiled binary addons (http://nodejs.org/api/addons.html)
27 | build/Release
28 |
29 | # Dependency directories
30 | node_modules
31 | jspm_packages
32 |
33 | # Optional npm cache directory
34 | .npm
35 |
36 | # Optional REPL history
37 | .node_repl_history
38 |
39 | # Others
40 | .DS_Store
41 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "make-github-greater",
3 | "version": "1.0.1",
4 | "description": "Let's make GitHub greater.",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [
10 | "GitHub"
11 | ],
12 | "devDependencies": {
13 | "babel-preset-es2015": "^6.3.13",
14 | "datauri": "^1.0.4",
15 | "del": "^2.2.0",
16 | "gulp": "^3.8.9",
17 | "gulp-babel": "^6.1.1",
18 | "gulp-concat": "^2.6.0",
19 | "gulp-rename": "^1.2.2",
20 | "gulp-replace": "^0.5.4",
21 | "gulp-uglify": "^1.5.1",
22 | "merge-stream": "^1.0.0",
23 | "plist": "^2.0.1",
24 | "rename": "^1.0.3",
25 | "run-sequence": "^1.1.5"
26 | },
27 | "author": "Justineo (justice360@gmail.com)",
28 | "license": "MIT"
29 | }
30 |
--------------------------------------------------------------------------------
/extensions/edge/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "author": "Justineo (justice360@gmail.com)",
3 | "background": {
4 | "page": "background.html",
5 | "persistent": true
6 | },
7 | "description": "Let's make GitHub greater.",
8 | "externally_connectable": {
9 | "matches": [
10 | "*://justineo.github.io/*"
11 | ]
12 | },
13 | "icons": {
14 | "128": "icon.png"
15 | },
16 | "manifest_version": 2,
17 | "name": "Make GitHub Greater",
18 | "optional_permissions": [
19 | ""
20 | ],
21 | "options_page": "options.html",
22 | "permissions": [
23 | "webNavigation",
24 | "tabs",
25 | "storage",
26 | "https://github.com/*"
27 | ],
28 | "version": "1.0.1",
29 | "-ms-preload": {
30 | "backgroundScript": "backgroundScriptsAPIBridge.js",
31 | "contentScript": "contentScriptsAPIBridge.js"
32 | }
33 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 GU Yiling
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/extensions/make-github-greater.safariextension/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Author
6 | Justineo
7 | Builder Version
8 | 12602.3.12.0.1
9 | CFBundleDisplayName
10 | Make GitHub Greater
11 | CFBundleIdentifier
12 | justineo.github.io.make-github-greater
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleShortVersionString
16 | 1.0.1
17 | CFBundleVersion
18 | 1.0.1
19 | Content
20 |
21 | Scripts
22 |
23 | End
24 |
25 | kolor.js
26 | main.js
27 |
28 |
29 |
30 | Description
31 | Let's make GitHub greater.
32 | DeveloperIdentifier
33 | 0000000000
34 | ExtensionInfoDictionaryVersion
35 | 1.0
36 | Permissions
37 |
38 | Website Access
39 |
40 | Allowed Domains
41 |
42 | http://github.com/*
43 | https://github.com/*
44 |
45 | Include Secure Pages
46 |
47 | Level
48 | Some
49 |
50 |
51 | Website
52 | https://justineo.github.io/make-github-greater
53 |
54 |
--------------------------------------------------------------------------------
/extensions/chrome/options.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Make GitHub Greater Options
6 |
87 |
88 |
89 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/extensions/edge/options.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Make GitHub Greater Options
6 |
87 |
88 |
89 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/extensions/edge/options.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const ITEM_TPL = `{{#domains}}{{/domains}}`;
4 | const GH_DOMAIN = 'github.com';
5 |
6 | let list = $('#domains');
7 | let saveBtn = $('#save');
8 | let cancelBtn = $('#cancel');
9 | let addBtn = $('#add');
10 | let msg = $('#message');
11 | let current;
12 | let storage = browser.storage.sync || browser.storage.local;
13 |
14 | function toOrigins(name) {
15 | return [`http://${name}/*`, `https://${name}/*`];
16 | }
17 |
18 | function concat(a, b) {
19 | return a.concat(b);
20 | }
21 |
22 | function restore() {
23 | storage.get({ domains: [] }, item => {
24 | current = item.domains;
25 | list.append(Mustache.render(ITEM_TPL, { domains: current }));
26 | });
27 | }
28 |
29 | function save() {
30 | let domains = [];
31 | $('.domain').each(function () {
32 | let domain = $(this).val().trim();
33 | if (domains.indexOf(domain) === -1 && domain !== GH_DOMAIN) {
34 | domains.push(domain);
35 | }
36 | });
37 |
38 | let options = {};
39 | Object.assign(options, { domains });
40 | current = domains;
41 |
42 | storage.set(options, () => {
43 | browser.runtime.sendMessage({ event: 'optionschange' }, response => {
44 | if (response.success) {
45 | window.close();
46 | } else {
47 | log('Something went wrong.');
48 | }
49 | });
50 | });
51 | }
52 |
53 | function cancel() {
54 | window.close();
55 | }
56 |
57 | function addRow() {
58 | if ($('.domain').length >= 4) {
59 | log('That should be enough.', 3000);
60 | return;
61 | }
62 | list.append(Mustache.render(ITEM_TPL, {
63 | domains: ['']
64 | }));
65 | }
66 |
67 | function removeRow() {
68 | $(this).parent().remove();
69 | }
70 |
71 | let logTimer;
72 | function log(message, duration) {
73 | clearTimeout(logTimer);
74 | msg.css({opacity: 1}).html(message);
75 | if (duration) {
76 | logTimer = setTimeout(() => {
77 | msg.animate({ opacity: 0 }, 500, () => msg.empty());
78 | }, duration);
79 | }
80 | }
81 |
82 | $(() => {
83 | saveBtn.on('click', save);
84 | cancelBtn.on('click', cancel);
85 | addBtn.on('click', addRow);
86 | list.on('keypress', '.domain', e => {
87 | if (e.which === 13) {
88 | save();
89 | }
90 | });
91 | list.on('click', '.remove', removeRow);
92 |
93 | restore();
94 | });
95 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Make GitHub Greater
2 |
3 | > Inspired by [MakeGitHubGreatAgain](https://github.com/DennisSnijder/MakeGithubGreatAgain).
4 |
5 | Double click the empty space on the site header and choose your own background color! The text color will automatically switch (between black and white) according to the calculated contrast ratio.
6 |
7 | 
8 |
9 |
10 | ## Installation
11 |
12 | ### Published versions
13 |
14 | * [Chrome extension](https://chrome.google.com/webstore/detail/make-github-greater/emijicijbkhnobkceaeaekiiapnkdnlp)
15 | * [Firefox add-on](https://addons.mozilla.org/zh-CN/firefox/addon/make-github-greater/)
16 | * [Opera extension](https://addons.opera.com/zh-cn/extensions/details/make-github-greater/)
17 | * [Userscript](https://justineo.github.io/make-github-greater/userscript/dist/make-github-greater.user.js)
18 |
19 | ### Manual installation
20 |
21 | * [Edge extension](https://github.com/Justineo/make-github-greater/raw/master/extensions/packed/make-github-greater.edge.zip)
22 |
23 | See [Adding and removing extensions for Microsoft Edge](https://docs.microsoft.com/en-us/microsoft-edge/extensions/guides/adding-and-removing-extensions).
24 |
25 | * [Safari extension](https://minhaskamal.github.io/DownGit/#/home?url=https://github.com/Justineo/make-github-greater/tree/master/extensions/make-github-greater.safariextension)
26 |
27 | See [Using Extension Builder](https://developer.apple.com/library/content/documentation/Tools/Conceptual/SafariExtensionGuide/UsingExtensionBuilder/UsingExtensionBuilder.html#//apple_ref/doc/uid/TP40009977-CH2-SW10) to learn how to activate the Extension Builder. And then:
28 |
29 | 1. Use “Add Extension” instead of “Create Extension”.
30 | 2. Choose the downloaded directory.
31 | 3. Click “install” to load the extension.
32 |
33 | ## FAQ
34 |
35 | * Why Chrome warns me the extension might read my browser history?
36 |
37 | It's because Make GitHub Greater uses `webNavigation` module to dynamically inject content scripts (to support GitHub Enterprise). Make GitHub Greater won't track or record any of these private data.
38 |
39 | * Why access token isn't working for me?
40 |
41 | Now Make GitHub Greater is saving user's private access token into `localStorage`. `localStorage` has a limit of 5MB and the problem might be other extensions have consumed too much storage that Make GitHub Greater failed to save access tokens.
42 |
43 | ## Options
44 |
45 | For browser extension versions (excluding Safari version), Make GitHub Greater now provide following option:
46 |
47 | * Domain
48 |
49 | Use this option to set custom domains for your GitHub Enterprise service. Note that you don't need to set `github.com` because it's always included. You may be asked to grant additional permissions for those domains.
50 |
--------------------------------------------------------------------------------
/extensions/edge/background.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | let contentJS = [
4 | 'kolor.js',
5 | 'main.js'
6 | ];
7 |
8 | let contentCSS = [];
9 |
10 | const INJECTORS = {
11 | js: browser.tabs.executeScript.bind(browser.tabs),
12 | css: browser.tabs.insertCSS.bind(browser.tabs)
13 | };
14 |
15 | let storage = browser.storage.sync || browser.storage.local;
16 |
17 | function inject(id, files, type, callback) {
18 | let injector = INJECTORS[type];
19 | if (!injector) {
20 | return;
21 | }
22 |
23 | // inject code
24 | if (typeof files === 'string') {
25 | injector(id, {
26 | code: files
27 | }, callback);
28 | return;
29 | }
30 |
31 | // inject files
32 | let index = 0;
33 | let remaining = files.length;
34 |
35 | function injectNext() {
36 | if (remaining > 0) {
37 | injector(id, {
38 | file: files[index]
39 | }, () => {
40 | console.log('"' + files[index] + '" is injected.');
41 | index++;
42 | remaining--;
43 | injectNext();
44 | });
45 | } else {
46 | if (typeof callback === 'function') {
47 | callback();
48 | }
49 | }
50 | }
51 | injectNext();
52 | }
53 |
54 | function injectJS(id, content, callback) {
55 | inject(id, content, 'js', callback);
56 | }
57 |
58 | function injectCSS(id, content, callback) {
59 | inject(id, content, 'css', callback);
60 | }
61 |
62 | const GITHUB_DOMAIN = 'github.com';
63 |
64 | function injector(details) {
65 | let tab = details.tabId;
66 | injectJS(tab, contentJS);
67 | injectCSS(tab, contentCSS);
68 | }
69 |
70 | function bindInjector(domains) {
71 | // always enable on GitHub
72 | if (domains.indexOf(GITHUB_DOMAIN) === -1) {
73 | domains.push(GITHUB_DOMAIN);
74 | }
75 | let filters = domains.map((domain) => { return { hostEquals: domain }; });
76 | if (browser.webNavigation.onCommitted.hasListener(injector)) {
77 | browser.webNavigation.onCommitted.removeListener(injector);
78 | }
79 | // rebind injector with different domains
80 | browser.webNavigation.onCommitted.addListener(injector, { url: filters });
81 | }
82 |
83 | function init() {
84 | storage.get({
85 | domains: []
86 | }, (items) => bindInjector(items.domains));
87 | }
88 |
89 | browser.runtime.onInstalled.addListener(init);
90 | browser.runtime.onMessage.addListener((message, sender, respond) => {
91 | if (message.event === 'optionschange') {
92 | init();
93 | respond({ success: true });
94 | }
95 | });
96 |
97 | init();
98 |
99 | browser.runtime.onMessageExternal.addListener((request, sender, sendResponse) => {
100 | if (request) {
101 | if (request.message) {
102 | if (request.message === 'version') {
103 | sendResponse({ version: browser.runtime.getManifest().version });
104 | }
105 | }
106 | }
107 | });
108 |
--------------------------------------------------------------------------------
/extensions/chrome/background.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | let contentJS = [
4 | 'kolor.js',
5 | 'main.js'
6 | ];
7 |
8 | let contentCSS = [];
9 |
10 | const INJECTORS = {
11 | js: chrome.tabs.executeScript.bind(chrome.tabs),
12 | css: chrome.tabs.insertCSS.bind(chrome.tabs)
13 | };
14 |
15 | let storage = chrome.storage.sync || chrome.storage.local;
16 |
17 | function inject(id, files, type, callback) {
18 | let injector = INJECTORS[type];
19 | if (!injector) {
20 | return;
21 | }
22 |
23 | // inject code
24 | if (typeof files === 'string') {
25 | injector(id, {
26 | code: files
27 | }, callback);
28 | return;
29 | }
30 |
31 | // inject files
32 | let index = 0;
33 | let remaining = files.length;
34 |
35 | function injectNext() {
36 | if (remaining > 0) {
37 | injector(id, {
38 | file: files[index],
39 | runAt: 'document_start'
40 | }, () => {
41 | console.log('"' + files[index] + '" is injected.');
42 | index++;
43 | remaining--;
44 | injectNext();
45 | });
46 | } else {
47 | if (typeof callback === 'function') {
48 | callback();
49 | }
50 | }
51 | }
52 | injectNext();
53 | }
54 |
55 | function injectJS(id, content, callback) {
56 | inject(id, content, 'js', callback);
57 | }
58 |
59 | function injectCSS(id, content, callback) {
60 | inject(id, content, 'css', callback);
61 | }
62 |
63 | const GITHUB_DOMAIN = 'github.com';
64 |
65 | function injector(details) {
66 | let tab = details.tabId;
67 | injectJS(tab, contentJS);
68 | injectCSS(tab, contentCSS);
69 | }
70 |
71 | function bindInjector(domains) {
72 | // always enable on GitHub
73 | if (domains.indexOf(GITHUB_DOMAIN) === -1) {
74 | domains.push(GITHUB_DOMAIN);
75 | }
76 | let filters = domains.map((domain) => { return { hostEquals: domain }; });
77 | if (chrome.webNavigation.onCommitted.hasListener(injector)) {
78 | chrome.webNavigation.onCommitted.removeListener(injector);
79 | }
80 | // rebind injector with different domains
81 | chrome.webNavigation.onCommitted.addListener(injector, { url: filters });
82 | }
83 |
84 | function init() {
85 | storage.get({
86 | domains: []
87 | }, (items) => bindInjector(items.domains));
88 | }
89 |
90 | chrome.runtime.onInstalled.addListener(init);
91 | chrome.runtime.onMessage.addListener((message, sender, respond) => {
92 | if (message.event === 'optionschange') {
93 | init();
94 | respond({ success: true });
95 | }
96 | });
97 |
98 | init();
99 |
100 | chrome.runtime.onMessageExternal.addListener((request, sender, sendResponse) => {
101 | if (request) {
102 | if (request.message) {
103 | if (request.message === 'version') {
104 | sendResponse({ version: chrome.runtime.getManifest().version });
105 | }
106 | }
107 | }
108 | });
109 |
--------------------------------------------------------------------------------
/extensions/chrome/options.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const ITEM_TPL = `{{#domains}}{{/domains}}`;
4 | const GH_DOMAIN = 'github.com';
5 |
6 | let list = $('#domains');
7 | let saveBtn = $('#save');
8 | let cancelBtn = $('#cancel');
9 | let addBtn = $('#add');
10 | let msg = $('#message');
11 | let current;
12 | let storage = chrome.storage.sync || chrome.storage.local;
13 |
14 | function toOrigins(name) {
15 | return [`http://${name}/*`, `https://${name}/*`];
16 | }
17 |
18 | function concat(a, b) {
19 | return a.concat(b);
20 | }
21 |
22 | function restore() {
23 | storage.get({ domains: [] }, item => {
24 | current = item.domains;
25 | list.append(Mustache.render(ITEM_TPL, { domains: current }));
26 | });
27 | }
28 |
29 | function save() {
30 | let domains = [];
31 | $('.domain').each(function () {
32 | let domain = $(this).val().trim();
33 | if (domains.indexOf(domain) === -1 && domain !== GH_DOMAIN) {
34 | domains.push(domain);
35 | }
36 | });
37 |
38 | let revoking = current.filter(domain => {
39 | return domains.indexOf(domain) === -1;
40 | }).map(toOrigins).reduce(concat, []);
41 |
42 | chrome.permissions.remove({
43 | origins: revoking
44 | }, removed => {
45 | let granting = domains.map(toOrigins).reduce(concat, []);
46 | chrome.permissions.request({
47 | origins: granting
48 | }, granted => {
49 | let options = {};
50 | if (granted) {
51 | Object.assign(options, { domains });
52 | current = domains;
53 | } else {
54 | log('Domain permission denied.');
55 | }
56 |
57 | storage.set(options, () => {
58 | chrome.runtime.sendMessage({ event: 'optionschange' }, response => {
59 | if (response.success) {
60 | window.close();
61 | } else {
62 | log('Something went wrong.');
63 | }
64 | });
65 | });
66 | });
67 | });
68 | }
69 |
70 | function cancel() {
71 | window.close();
72 | }
73 |
74 | function addRow() {
75 | if ($('.domain').length >= 4) {
76 | log('That should be enough.', 3000);
77 | return;
78 | }
79 | list.append(Mustache.render(ITEM_TPL, {
80 | domains: ['']
81 | }));
82 | }
83 |
84 | function removeRow() {
85 | $(this).parent().remove();
86 | }
87 |
88 | let logTimer;
89 | function log(message, duration) {
90 | clearTimeout(logTimer);
91 | msg.css({opacity: 1}).html(message);
92 | if (duration) {
93 | logTimer = setTimeout(() => {
94 | msg.animate({ opacity: 0 }, 500, () => msg.empty());
95 | }, duration);
96 | }
97 | }
98 |
99 | $(() => {
100 | saveBtn.on('click', save);
101 | cancelBtn.on('click', cancel);
102 | addBtn.on('click', addRow);
103 | list.on('keypress', '.domain', e => {
104 | if (e.which === 13) {
105 | save();
106 | }
107 | });
108 | list.on('click', '.remove', removeRow);
109 |
110 | restore();
111 | });
112 |
--------------------------------------------------------------------------------
/src/main.js:
--------------------------------------------------------------------------------
1 | const EXCLUDE = 'a, .header-search, .header-nav';
2 | const ITEM_KEY = 'mgg-current';
3 |
4 | function isInteractive(elem) {
5 | while (elem !== document.body) {
6 | if (elem.matches(EXCLUDE)) {
7 | return true;
8 | }
9 | elem = elem.parentNode;
10 | }
11 | return false;
12 | }
13 |
14 | function asap(selector, callback) {
15 | function tryInit() {
16 | if (document && document.querySelector(selector)) {
17 | document.removeEventListener('DOMNodeInserted', tryInit);
18 | document.removeEventListener('DOMContentLoaded', tryInit);
19 | console.log(performance.now());
20 | callback();
21 | }
22 | }
23 |
24 | if (document.readyState !== 'loading') {
25 | tryInit();
26 | } else {
27 | document.addEventListener('DOMNodeInserted', tryInit);
28 | document.addEventListener('DOMContentLoaded', tryInit);
29 | }
30 | }
31 |
32 | let style;
33 | let white = kolor('#fff');
34 | let black = kolor('#000');
35 |
36 | function updateStyle(backgroundColor) {
37 | let textColor = backgroundColor.contrastRatio(white) > backgroundColor.contrastRatio(black)
38 | ? '#fff' : '#000';
39 |
40 | let color = kolor(textColor);
41 | style.textContent = `
42 | .header {
43 | background-color: ${backgroundColor};
44 | border-bottom: 1px solid ${kolor(color.fadeOut(0.925))};
45 | }
46 |
47 | .header-logo-invertocat,
48 | .header .header-search-wrapper {
49 | color: ${color};
50 | }
51 |
52 | .header .header-search-wrapper {
53 | background-color: ${kolor(color.fadeOut(0.875))};
54 | }
55 |
56 | .header .header-search-wrapper.focus {
57 | background-color: ${kolor(color.fadeOut(0.825))};
58 | }
59 |
60 | .header-nav-link {
61 | color: ${kolor(color.fadeOut(0.25))};
62 | }
63 |
64 | .header .header-search-input::-webkit-input-placeholder {
65 | color: ${kolor(color.fadeOut(0.25))};
66 | }
67 |
68 | .header .header-search-input::-moz-placeholder {
69 | color: ${kolor(color.fadeOut(0.25))};
70 | }
71 |
72 | .header-logo-invertocat:hover,
73 | .header-nav-link:hover,
74 | .header-nav-link:focus {
75 | color: ${color};
76 | }
77 |
78 | .header-nav-link:hover .dropdown-caret,
79 | .header-nav-link:focus .dropdown-caret {
80 | border-top-color: ${color}
81 | }
82 |
83 | .header .header-search-scope {
84 | color: ${kolor(color.fadeOut(0.25))};
85 | border-right-color: ${backgroundColor};
86 | }
87 |
88 | .header .header-search-wrapper.focus .header-search-scope {
89 | color: ${color};
90 | background-color: ${kolor(color.fadeOut(0.925))};
91 | border-right-color: ${backgroundColor};
92 | }
93 |
94 | .notification-indicator .mail-status {
95 | border-color: ${backgroundColor};
96 | }
97 | `;
98 | }
99 |
100 | let current = localStorage.getItem(ITEM_KEY);
101 | function load() {
102 | style = document.createElement('style');
103 | document.body.appendChild(style);
104 |
105 | if (current) {
106 | updateStyle(kolor(current));
107 | }
108 | }
109 |
110 | function init() {
111 | let header = document.querySelector('.header');
112 | if (!header) {
113 | return;
114 | }
115 |
116 | let picker = document.createElement('input');
117 | picker.type = 'color';
118 | document.body.appendChild(picker);
119 | picker.style.cssText = `position: absolute; top: -${picker.offsetHeight}px; left: -${picker.offsetWidth}px;`;
120 | picker.value = current;
121 | picker.addEventListener('input', () => {
122 | let {value} = picker;
123 | localStorage.setItem(ITEM_KEY, value);
124 | updateStyle(kolor(value));
125 | });
126 |
127 | header.addEventListener('dblclick', ({target}) => {
128 | if (isInteractive(target)) {
129 | return;
130 | }
131 |
132 | picker.click();
133 | });
134 | }
135 |
136 | asap('body', load);
137 | asap('.header', init);
138 |
--------------------------------------------------------------------------------
/extensions/edge/main.js:
--------------------------------------------------------------------------------
1 | const EXCLUDE = 'a, .header-search, .header-nav';
2 | const ITEM_KEY = 'mgg-current';
3 |
4 | function isInteractive(elem) {
5 | while (elem !== document.body) {
6 | if (elem.matches(EXCLUDE)) {
7 | return true;
8 | }
9 | elem = elem.parentNode;
10 | }
11 | return false;
12 | }
13 |
14 | function asap(selector, callback) {
15 | function tryInit() {
16 | if (document && document.querySelector(selector)) {
17 | document.removeEventListener('DOMNodeInserted', tryInit);
18 | document.removeEventListener('DOMContentLoaded', tryInit);
19 | console.log(performance.now());
20 | callback();
21 | }
22 | }
23 |
24 | if (document.readyState !== 'loading') {
25 | tryInit();
26 | } else {
27 | document.addEventListener('DOMNodeInserted', tryInit);
28 | document.addEventListener('DOMContentLoaded', tryInit);
29 | }
30 | }
31 |
32 | let style;
33 | let white = kolor('#fff');
34 | let black = kolor('#000');
35 |
36 | function updateStyle(backgroundColor) {
37 | let textColor = backgroundColor.contrastRatio(white) > backgroundColor.contrastRatio(black)
38 | ? '#fff' : '#000';
39 |
40 | let color = kolor(textColor);
41 | style.textContent = `
42 | .header {
43 | background-color: ${backgroundColor};
44 | border-bottom: 1px solid ${kolor(color.fadeOut(0.925))};
45 | }
46 |
47 | .header-logo-invertocat,
48 | .header .header-search-wrapper {
49 | color: ${color};
50 | }
51 |
52 | .header .header-search-wrapper {
53 | background-color: ${kolor(color.fadeOut(0.875))};
54 | }
55 |
56 | .header .header-search-wrapper.focus {
57 | background-color: ${kolor(color.fadeOut(0.825))};
58 | }
59 |
60 | .header-nav-link {
61 | color: ${kolor(color.fadeOut(0.25))};
62 | }
63 |
64 | .header .header-search-input::-webkit-input-placeholder {
65 | color: ${kolor(color.fadeOut(0.25))};
66 | }
67 |
68 | .header .header-search-input::-moz-placeholder {
69 | color: ${kolor(color.fadeOut(0.25))};
70 | }
71 |
72 | .header-logo-invertocat:hover,
73 | .header-nav-link:hover,
74 | .header-nav-link:focus {
75 | color: ${color};
76 | }
77 |
78 | .header-nav-link:hover .dropdown-caret,
79 | .header-nav-link:focus .dropdown-caret {
80 | border-top-color: ${color}
81 | }
82 |
83 | .header .header-search-scope {
84 | color: ${kolor(color.fadeOut(0.25))};
85 | border-right-color: ${backgroundColor};
86 | }
87 |
88 | .header .header-search-wrapper.focus .header-search-scope {
89 | color: ${color};
90 | background-color: ${kolor(color.fadeOut(0.925))};
91 | border-right-color: ${backgroundColor};
92 | }
93 |
94 | .notification-indicator .mail-status {
95 | border-color: ${backgroundColor};
96 | }
97 | `;
98 | }
99 |
100 | let current = localStorage.getItem(ITEM_KEY);
101 | function load() {
102 | style = document.createElement('style');
103 | document.body.appendChild(style);
104 |
105 | if (current) {
106 | updateStyle(kolor(current));
107 | }
108 | }
109 |
110 | function init() {
111 | let header = document.querySelector('.header');
112 | if (!header) {
113 | return;
114 | }
115 |
116 | let picker = document.createElement('input');
117 | picker.type = 'color';
118 | document.body.appendChild(picker);
119 | picker.style.cssText = `position: absolute; top: -${picker.offsetHeight}px; left: -${picker.offsetWidth}px;`;
120 | picker.value = current;
121 | picker.addEventListener('input', () => {
122 | let {value} = picker;
123 | localStorage.setItem(ITEM_KEY, value);
124 | updateStyle(kolor(value));
125 | });
126 |
127 | header.addEventListener('dblclick', ({target}) => {
128 | if (isInteractive(target)) {
129 | return;
130 | }
131 |
132 | picker.click();
133 | });
134 | }
135 |
136 | asap('body', load);
137 | asap('.header', init);
138 |
--------------------------------------------------------------------------------
/extensions/chrome/main.js:
--------------------------------------------------------------------------------
1 | const EXCLUDE = 'a, .header-search, .header-nav';
2 | const ITEM_KEY = 'mgg-current';
3 |
4 | function isInteractive(elem) {
5 | while (elem !== document.body) {
6 | if (elem.matches(EXCLUDE)) {
7 | return true;
8 | }
9 | elem = elem.parentNode;
10 | }
11 | return false;
12 | }
13 |
14 | function asap(selector, callback) {
15 | function tryInit() {
16 | if (document && document.querySelector(selector)) {
17 | document.removeEventListener('DOMNodeInserted', tryInit);
18 | document.removeEventListener('DOMContentLoaded', tryInit);
19 | console.log(performance.now());
20 | callback();
21 | }
22 | }
23 |
24 | if (document.readyState !== 'loading') {
25 | tryInit();
26 | } else {
27 | document.addEventListener('DOMNodeInserted', tryInit);
28 | document.addEventListener('DOMContentLoaded', tryInit);
29 | }
30 | }
31 |
32 | let style;
33 | let white = kolor('#fff');
34 | let black = kolor('#000');
35 |
36 | function updateStyle(backgroundColor) {
37 | let textColor = backgroundColor.contrastRatio(white) > backgroundColor.contrastRatio(black)
38 | ? '#fff' : '#000';
39 |
40 | let color = kolor(textColor);
41 | style.textContent = `
42 | .header {
43 | background-color: ${backgroundColor};
44 | border-bottom: 1px solid ${kolor(color.fadeOut(0.925))};
45 | }
46 |
47 | .header-logo-invertocat,
48 | .header .header-search-wrapper {
49 | color: ${color};
50 | }
51 |
52 | .header .header-search-wrapper {
53 | background-color: ${kolor(color.fadeOut(0.875))};
54 | }
55 |
56 | .header .header-search-wrapper.focus {
57 | background-color: ${kolor(color.fadeOut(0.825))};
58 | }
59 |
60 | .header-nav-link {
61 | color: ${kolor(color.fadeOut(0.25))};
62 | }
63 |
64 | .header .header-search-input::-webkit-input-placeholder {
65 | color: ${kolor(color.fadeOut(0.25))};
66 | }
67 |
68 | .header .header-search-input::-moz-placeholder {
69 | color: ${kolor(color.fadeOut(0.25))};
70 | }
71 |
72 | .header-logo-invertocat:hover,
73 | .header-nav-link:hover,
74 | .header-nav-link:focus {
75 | color: ${color};
76 | }
77 |
78 | .header-nav-link:hover .dropdown-caret,
79 | .header-nav-link:focus .dropdown-caret {
80 | border-top-color: ${color}
81 | }
82 |
83 | .header .header-search-scope {
84 | color: ${kolor(color.fadeOut(0.25))};
85 | border-right-color: ${backgroundColor};
86 | }
87 |
88 | .header .header-search-wrapper.focus .header-search-scope {
89 | color: ${color};
90 | background-color: ${kolor(color.fadeOut(0.925))};
91 | border-right-color: ${backgroundColor};
92 | }
93 |
94 | .notification-indicator .mail-status {
95 | border-color: ${backgroundColor};
96 | }
97 | `;
98 | }
99 |
100 | let current = localStorage.getItem(ITEM_KEY);
101 | function load() {
102 | style = document.createElement('style');
103 | document.body.appendChild(style);
104 |
105 | if (current) {
106 | updateStyle(kolor(current));
107 | }
108 | }
109 |
110 | function init() {
111 | let header = document.querySelector('.header');
112 | if (!header) {
113 | return;
114 | }
115 |
116 | let picker = document.createElement('input');
117 | picker.type = 'color';
118 | document.body.appendChild(picker);
119 | picker.style.cssText = `position: absolute; top: -${picker.offsetHeight}px; left: -${picker.offsetWidth}px;`;
120 | picker.value = current;
121 | picker.addEventListener('input', () => {
122 | let {value} = picker;
123 | localStorage.setItem(ITEM_KEY, value);
124 | updateStyle(kolor(value));
125 | });
126 |
127 | header.addEventListener('dblclick', ({target}) => {
128 | if (isInteractive(target)) {
129 | return;
130 | }
131 |
132 | picker.click();
133 | });
134 | }
135 |
136 | asap('body', load);
137 | asap('.header', init);
138 |
--------------------------------------------------------------------------------
/extensions/firefox/data/main.js:
--------------------------------------------------------------------------------
1 | const EXCLUDE = 'a, .header-search, .header-nav';
2 | const ITEM_KEY = 'mgg-current';
3 |
4 | function isInteractive(elem) {
5 | while (elem !== document.body) {
6 | if (elem.matches(EXCLUDE)) {
7 | return true;
8 | }
9 | elem = elem.parentNode;
10 | }
11 | return false;
12 | }
13 |
14 | function asap(selector, callback) {
15 | function tryInit() {
16 | if (document && document.querySelector(selector)) {
17 | document.removeEventListener('DOMNodeInserted', tryInit);
18 | document.removeEventListener('DOMContentLoaded', tryInit);
19 | console.log(performance.now());
20 | callback();
21 | }
22 | }
23 |
24 | if (document.readyState !== 'loading') {
25 | tryInit();
26 | } else {
27 | document.addEventListener('DOMNodeInserted', tryInit);
28 | document.addEventListener('DOMContentLoaded', tryInit);
29 | }
30 | }
31 |
32 | let style;
33 | let white = kolor('#fff');
34 | let black = kolor('#000');
35 |
36 | function updateStyle(backgroundColor) {
37 | let textColor = backgroundColor.contrastRatio(white) > backgroundColor.contrastRatio(black)
38 | ? '#fff' : '#000';
39 |
40 | let color = kolor(textColor);
41 | style.textContent = `
42 | .header {
43 | background-color: ${backgroundColor};
44 | border-bottom: 1px solid ${kolor(color.fadeOut(0.925))};
45 | }
46 |
47 | .header-logo-invertocat,
48 | .header .header-search-wrapper {
49 | color: ${color};
50 | }
51 |
52 | .header .header-search-wrapper {
53 | background-color: ${kolor(color.fadeOut(0.875))};
54 | }
55 |
56 | .header .header-search-wrapper.focus {
57 | background-color: ${kolor(color.fadeOut(0.825))};
58 | }
59 |
60 | .header-nav-link {
61 | color: ${kolor(color.fadeOut(0.25))};
62 | }
63 |
64 | .header .header-search-input::-webkit-input-placeholder {
65 | color: ${kolor(color.fadeOut(0.25))};
66 | }
67 |
68 | .header .header-search-input::-moz-placeholder {
69 | color: ${kolor(color.fadeOut(0.25))};
70 | }
71 |
72 | .header-logo-invertocat:hover,
73 | .header-nav-link:hover,
74 | .header-nav-link:focus {
75 | color: ${color};
76 | }
77 |
78 | .header-nav-link:hover .dropdown-caret,
79 | .header-nav-link:focus .dropdown-caret {
80 | border-top-color: ${color}
81 | }
82 |
83 | .header .header-search-scope {
84 | color: ${kolor(color.fadeOut(0.25))};
85 | border-right-color: ${backgroundColor};
86 | }
87 |
88 | .header .header-search-wrapper.focus .header-search-scope {
89 | color: ${color};
90 | background-color: ${kolor(color.fadeOut(0.925))};
91 | border-right-color: ${backgroundColor};
92 | }
93 |
94 | .notification-indicator .mail-status {
95 | border-color: ${backgroundColor};
96 | }
97 | `;
98 | }
99 |
100 | let current = localStorage.getItem(ITEM_KEY);
101 | function load() {
102 | style = document.createElement('style');
103 | document.body.appendChild(style);
104 |
105 | if (current) {
106 | updateStyle(kolor(current));
107 | }
108 | }
109 |
110 | function init() {
111 | let header = document.querySelector('.header');
112 | if (!header) {
113 | return;
114 | }
115 |
116 | let picker = document.createElement('input');
117 | picker.type = 'color';
118 | document.body.appendChild(picker);
119 | picker.style.cssText = `position: absolute; top: -${picker.offsetHeight}px; left: -${picker.offsetWidth}px;`;
120 | picker.value = current;
121 | picker.addEventListener('input', () => {
122 | let {value} = picker;
123 | localStorage.setItem(ITEM_KEY, value);
124 | updateStyle(kolor(value));
125 | });
126 |
127 | header.addEventListener('dblclick', ({target}) => {
128 | if (isInteractive(target)) {
129 | return;
130 | }
131 |
132 | picker.click();
133 | });
134 | }
135 |
136 | asap('body', load);
137 | asap('.header', init);
138 |
--------------------------------------------------------------------------------
/extensions/make-github-greater.safariextension/main.js:
--------------------------------------------------------------------------------
1 | const EXCLUDE = 'a, .header-search, .header-nav';
2 | const ITEM_KEY = 'mgg-current';
3 |
4 | function isInteractive(elem) {
5 | while (elem !== document.body) {
6 | if (elem.matches(EXCLUDE)) {
7 | return true;
8 | }
9 | elem = elem.parentNode;
10 | }
11 | return false;
12 | }
13 |
14 | function asap(selector, callback) {
15 | function tryInit() {
16 | if (document && document.querySelector(selector)) {
17 | document.removeEventListener('DOMNodeInserted', tryInit);
18 | document.removeEventListener('DOMContentLoaded', tryInit);
19 | console.log(performance.now());
20 | callback();
21 | }
22 | }
23 |
24 | if (document.readyState !== 'loading') {
25 | tryInit();
26 | } else {
27 | document.addEventListener('DOMNodeInserted', tryInit);
28 | document.addEventListener('DOMContentLoaded', tryInit);
29 | }
30 | }
31 |
32 | let style;
33 | let white = kolor('#fff');
34 | let black = kolor('#000');
35 |
36 | function updateStyle(backgroundColor) {
37 | let textColor = backgroundColor.contrastRatio(white) > backgroundColor.contrastRatio(black)
38 | ? '#fff' : '#000';
39 |
40 | let color = kolor(textColor);
41 | style.textContent = `
42 | .header {
43 | background-color: ${backgroundColor};
44 | border-bottom: 1px solid ${kolor(color.fadeOut(0.925))};
45 | }
46 |
47 | .header-logo-invertocat,
48 | .header .header-search-wrapper {
49 | color: ${color};
50 | }
51 |
52 | .header .header-search-wrapper {
53 | background-color: ${kolor(color.fadeOut(0.875))};
54 | }
55 |
56 | .header .header-search-wrapper.focus {
57 | background-color: ${kolor(color.fadeOut(0.825))};
58 | }
59 |
60 | .header-nav-link {
61 | color: ${kolor(color.fadeOut(0.25))};
62 | }
63 |
64 | .header .header-search-input::-webkit-input-placeholder {
65 | color: ${kolor(color.fadeOut(0.25))};
66 | }
67 |
68 | .header .header-search-input::-moz-placeholder {
69 | color: ${kolor(color.fadeOut(0.25))};
70 | }
71 |
72 | .header-logo-invertocat:hover,
73 | .header-nav-link:hover,
74 | .header-nav-link:focus {
75 | color: ${color};
76 | }
77 |
78 | .header-nav-link:hover .dropdown-caret,
79 | .header-nav-link:focus .dropdown-caret {
80 | border-top-color: ${color}
81 | }
82 |
83 | .header .header-search-scope {
84 | color: ${kolor(color.fadeOut(0.25))};
85 | border-right-color: ${backgroundColor};
86 | }
87 |
88 | .header .header-search-wrapper.focus .header-search-scope {
89 | color: ${color};
90 | background-color: ${kolor(color.fadeOut(0.925))};
91 | border-right-color: ${backgroundColor};
92 | }
93 |
94 | .notification-indicator .mail-status {
95 | border-color: ${backgroundColor};
96 | }
97 | `;
98 | }
99 |
100 | let current = localStorage.getItem(ITEM_KEY);
101 | function load() {
102 | style = document.createElement('style');
103 | document.body.appendChild(style);
104 |
105 | if (current) {
106 | updateStyle(kolor(current));
107 | }
108 | }
109 |
110 | function init() {
111 | let header = document.querySelector('.header');
112 | if (!header) {
113 | return;
114 | }
115 |
116 | let picker = document.createElement('input');
117 | picker.type = 'color';
118 | document.body.appendChild(picker);
119 | picker.style.cssText = `position: absolute; top: -${picker.offsetHeight}px; left: -${picker.offsetWidth}px;`;
120 | picker.value = current;
121 | picker.addEventListener('input', () => {
122 | let {value} = picker;
123 | localStorage.setItem(ITEM_KEY, value);
124 | updateStyle(kolor(value));
125 | });
126 |
127 | header.addEventListener('dblclick', ({target}) => {
128 | if (isInteractive(target)) {
129 | return;
130 | }
131 |
132 | picker.click();
133 | });
134 | }
135 |
136 | asap('body', load);
137 | asap('.header', init);
138 |
--------------------------------------------------------------------------------
/Gulpfile.js:
--------------------------------------------------------------------------------
1 | var gulp = require('gulp');
2 | var fs = require('fs');
3 | var path = require('path');
4 | var run = require('run-sequence');
5 | var merge = require('merge-stream');
6 | var del = require('del');
7 | var exec = require('child_process').exec;
8 | var replace = require('gulp-replace');
9 | var rename = require('gulp-rename');
10 | var concat = require('gulp-concat');
11 | var uglify = require('gulp-uglify');
12 | var babel = require('gulp-babel');
13 | var plist = require('plist');
14 | var pack = require('./package.json');
15 | var version = pack.version;
16 |
17 | function getCommentHandler() {
18 | var inMetaBlock = false;
19 | return function (node, comment) {
20 | var value = comment.value.trim();
21 | if (comment.type === 'comment2' && value.charAt(0) === '!') {
22 | return true;
23 | }
24 | if (value === '==UserScript==') {
25 | inMetaBlock = true;
26 | return true;
27 | }
28 | if (value === '==/UserScript==') {
29 | inMetaBlock = false;
30 | return true;
31 | }
32 | return inMetaBlock;
33 | }
34 | }
35 |
36 | gulp.task('userscript:prepare', function () {
37 | var main = gulp.src('./src/main.js')
38 | .pipe(babel({ presets: ['es2015'] }))
39 | .pipe(rename('main.userscript.js'))
40 | .pipe(gulp.dest('./tmp'));
41 | var meta = gulp.src('./userscript/src/metadata.js')
42 | .pipe(replace('{{version}}', version))
43 | .pipe(gulp.dest('./tmp'));
44 | return merge(main, meta);
45 | });
46 |
47 | gulp.task('userscript', ['userscript:prepare'], function () {
48 | var inMetaBlock = false;
49 | return gulp.src([
50 | './tmp/metadata.js',
51 | './src/kolor.js',
52 | './tmp/main.userscript.js'
53 | ])
54 | .pipe(concat('make-github-greater.user.js'))
55 | .pipe(uglify({
56 | preserveComments: getCommentHandler()
57 | }))
58 | .pipe(gulp.dest('./userscript/dist'));
59 | });
60 |
61 | gulp.task('chrome:cp', function () {
62 | var manifestPath = './extensions/chrome/manifest.json';
63 | var manifest = JSON.parse(fs.readFileSync(manifestPath, { encoding: 'utf8' }));
64 | manifest.version = version;
65 | fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, ' '));
66 |
67 | var targets = [
68 | './src/*', './icon.png'
69 | ];
70 | return gulp.src(targets)
71 | .pipe(gulp.dest('./extensions/chrome'));
72 | });
73 |
74 | gulp.task('safari:cp', function () {
75 | var infoPath = './extensions/make-github-greater.safariextension/Info.plist';
76 | var info = plist.parse(fs.readFileSync(infoPath, { encoding: 'utf8' }));
77 | info.CFBundleShortVersionString = version;
78 | info.CFBundleVersion = version;
79 | fs.writeFileSync(infoPath, plist.build(info));
80 |
81 | var targets = [
82 | './src/*', './icon.png'
83 | ];
84 | return gulp.src(targets)
85 | .pipe(gulp.dest('./extensions/make-github-greater.safariextension'));
86 | });
87 |
88 | gulp.task('edge:cp', function () {
89 | var manifestPath = './extensions/edge/manifest.json';
90 | var manifest = JSON.parse(fs.readFileSync(manifestPath, { encoding: 'utf8' }));
91 | manifest.version = version;
92 | fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, ' '));
93 |
94 | var targets = [
95 | './src/*', './icon.png'
96 | ];
97 | return gulp.src(targets)
98 | .pipe(gulp.dest('./extensions/edge'));
99 | });
100 |
101 | gulp.task('firefox:cp', function () {
102 | var fxPackPath = './extensions/firefox/package.json';
103 | var fxPack = JSON.parse(fs.readFileSync(fxPackPath, { encoding: 'utf8' }));
104 | fxPack.version = version;
105 | fs.writeFileSync(fxPackPath, JSON.stringify(fxPack, null, ' '));
106 |
107 | return gulp.src(['./src/*', './icon.png'])
108 | .pipe(gulp.dest('./extensions/firefox/data'));
109 | });
110 |
111 | gulp.task('chrome:zip', ['chrome:cp'], function (cb) {
112 | exec(
113 | 'find . -path \'*/.*\' -prune -o -type f -print | zip ../packed/make-github-greater.chrome.zip -@',
114 | { cwd: 'extensions/chrome' },
115 | function (error, stdout, stderr) {
116 | if (error) {
117 | return cb(error);
118 | } else {
119 | cb();
120 | }
121 | }
122 | );
123 | });
124 |
125 | gulp.task('edge:zip', ['edge:cp'], function (cb) {
126 | exec(
127 | 'find . -path \'*/.*\' -prune -o -type f -print | zip ../packed/make-github-greater.edge.zip -@',
128 | { cwd: 'extensions/edge' },
129 | function (error, stdout, stderr) {
130 | if (error) {
131 | return cb(error);
132 | } else {
133 | cb();
134 | }
135 | }
136 | );
137 | });
138 |
139 | gulp.task('firefox:xpi', ['firefox:cp'], function (cb) {
140 | exec('jpm xpi', {
141 | cwd: 'extensions/firefox'
142 | }, function (error, stdout, stderr) {
143 | if (error) {
144 | return cb(error);
145 | } else {
146 | fs.renameSync('./extensions/firefox/@' + pack.name + '-' + version + '.xpi', './extensions/packed/' + pack.name + '.xpi');
147 | cb();
148 | }
149 | });
150 | });
151 |
152 | gulp.task('opera:nex', ['chrome:zip'], function (cb) {
153 | exec(''
154 | + '"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"'
155 | + ' --pack-extension=' + path.join(__dirname, 'extensions/chrome')
156 | + ' --pack-extension-key=' + path.join(process.env.HOME, '.ssh/chrome.pem'),
157 | function (error, stdout, stderr) {
158 | if (error) {
159 | return cb(error);
160 | } else {
161 | fs.renameSync('./extensions/chrome.crx', './extensions/packed/make-github-greater.nex');
162 | cb();
163 | }
164 | }
165 | );
166 | });
167 |
168 | gulp.task('cleanup', function (cb) {
169 | return del(['./tmp']);
170 | });
171 |
172 | gulp.task('extensions', ['chrome:zip', 'edge:zip', 'firefox:xpi', 'opera:nex', 'safari:cp']);
173 | gulp.task('build', ['extensions', 'userscript']);
174 | gulp.task('default', function (cb) {
175 | run('build', 'cleanup', cb);
176 | });
177 |
--------------------------------------------------------------------------------
/extensions/edge/contentScriptsAPIBridge.js:
--------------------------------------------------------------------------------
1 | if (!Range.prototype["intersectsNode"]) {
2 | Range.prototype["intersectsNode"] = function (node) {
3 | let range = document.createRange();
4 | range.selectNode(node);
5 | return 0 > this.compareBoundaryPoints(Range.END_TO_START, range)
6 | && 0 < this.compareBoundaryPoints(Range.START_TO_END, range);
7 | };
8 | }
9 | var getExtensionProtocol = function () {
10 | if (typeof browser == "undefined") {
11 | if (typeof chrome !== "undefined")
12 | return "chrome-extension://";
13 | }
14 | else {
15 | return "ms-browser-extension://";
16 | }
17 | };
18 | class FakeEvent {
19 | addListener(callback) { }
20 | addRules(rules, callback) { }
21 | getRules(ruleIdentifiers, callback) { }
22 | hasListener(callback) { return false; }
23 | hasListeners() { return false; }
24 | removeRules(ruleIdentifiers, callback) { }
25 | removeListener(callback) { }
26 | }
27 | class EdgeBridgeHelper {
28 | constructor() {
29 | this.fakeEvent = new FakeEvent();
30 | }
31 | toAbsolutePath(relativePath) {
32 | if (relativePath.indexOf("ms-browser-extension://") == 0) {
33 | return relativePath.replace(myBrowser.runtime.getURL(""), "");
34 | }
35 | else if (relativePath.indexOf("/") != 0) {
36 | var absolutePath = "";
37 | var documentPath = document.location.pathname;
38 | absolutePath = documentPath.substring(0, documentPath.lastIndexOf("/") + 1);
39 | absolutePath += relativePath;
40 | return absolutePath;
41 | }
42 | return relativePath;
43 | }
44 | }
45 | var bridgeHelper = new EdgeBridgeHelper();
46 | class EdgeBridgeDebugLog {
47 | constructor() {
48 | this.CatchOnException = true;
49 | this.VerboseLogging = true;
50 | this.FailedCalls = {};
51 | this.SuccededCalls = {};
52 | this.DeprecatedCalls = {};
53 | this.BridgedCalls = {};
54 | this.UnavailableApis = {};
55 | this.EdgeIssues = {};
56 | }
57 | log(message) {
58 | try {
59 | if (this.VerboseLogging) {
60 | console.log(message);
61 | }
62 | }
63 | catch (e) {
64 | }
65 | }
66 | info(message) {
67 | try {
68 | if (this.VerboseLogging) {
69 | console.info(message);
70 | }
71 | }
72 | catch (e) {
73 | }
74 | }
75 | warn(message) {
76 | try {
77 | if (this.VerboseLogging) {
78 | console.warn(message);
79 | }
80 | }
81 | catch (e) {
82 | }
83 | }
84 | error(message) {
85 | try {
86 | if (this.VerboseLogging) {
87 | console.error(message);
88 | }
89 | }
90 | catch (e) {
91 | }
92 | }
93 | DoActionAndLog(action, name, deprecatedTo, bridgedTo) {
94 | var result;
95 | try {
96 | result = action();
97 | this.AddToCalledDictionary(this.SuccededCalls, name);
98 | if (typeof deprecatedTo !== "undefined" && typeof deprecatedTo !== "null") {
99 | this.warn("API Call Deprecated - Name: " + name + ", Please use " + deprecatedTo + " instead!");
100 | this.AddToCalledDictionary(this.DeprecatedCalls, name);
101 | }
102 | if (typeof bridgedTo !== "undefined" && typeof bridgedTo !== "null") {
103 | this.info("API Call '" + name + "' has been bridged to another Edge API: " + bridgedTo);
104 | this.AddToCalledDictionary(this.BridgedCalls, name);
105 | }
106 | return result;
107 | }
108 | catch (ex) {
109 | this.AddToCalledDictionary(this.FailedCalls, name);
110 | if (this.CatchOnException)
111 | this.error("API Call Failed: " + name + " - " + ex);
112 | else
113 | throw ex;
114 | }
115 | }
116 | LogEdgeIssue(name, message) {
117 | this.warn(message);
118 | this.AddToCalledDictionary(this.EdgeIssues, name);
119 | }
120 | LogUnavailbleApi(name, deprecatedTo) {
121 | this.warn("API Call '" + name + "' is not supported in Edge");
122 | this.AddToCalledDictionary(this.UnavailableApis, name);
123 | if (typeof deprecatedTo !== "undefined" && typeof deprecatedTo !== "null") {
124 | this.warn("API Call Deprecated - Name: " + name + ", Please use " + deprecatedTo + " instead!");
125 | this.AddToCalledDictionary(this.DeprecatedCalls, name);
126 | }
127 | }
128 | AddToCalledDictionary(dictionary, name) {
129 | if (typeof dictionary[name] !== "undefined") {
130 | dictionary[name]++;
131 | }
132 | else {
133 | dictionary[name] = 1;
134 | }
135 | }
136 | }
137 | var bridgeLog = new EdgeBridgeDebugLog();
138 | class EdgeExtensionBridge {
139 | getBackgroundPage() {
140 | return bridgeLog.DoActionAndLog(() => {
141 | return myBrowser.extension.getBackgroundPage();
142 | }, "extension.getBackgroundPage");
143 | }
144 | getURL(path) {
145 | return bridgeLog.DoActionAndLog(() => {
146 | return myBrowser.extension.getURL(path);
147 | }, "extension.getURL");
148 | }
149 | getViews(fetchProperties) {
150 | return bridgeLog.DoActionAndLog(() => {
151 | return myBrowser.extension.getViews(fetchProperties);
152 | }, "extension.getViews");
153 | }
154 | }
155 | class EdgeChromeExtensionBridge extends EdgeExtensionBridge {
156 | get onConnect() { return bridgeLog.DoActionAndLog(() => { return EdgeRuntimeBridge.prototype.onConnect; }, "extension.onConnect", "runtime.onConnect", "runtime.onConnect"); }
157 | get onMessage() { return bridgeLog.DoActionAndLog(() => { return myBrowser.runtime.onMessage; }, "extension.onMessage", "runtime.onMessage", "runtime.onMessage"); }
158 | get onRequest() { return bridgeLog.DoActionAndLog(() => { return myBrowser.runtime.onMessage; }, "extension.onRequest", "runtime.onMessage", "runtime.onMessage"); }
159 | get onRequestExternal() { return bridgeLog.DoActionAndLog(() => { return myBrowser.runtime.onMessageExternal; }, "extension.onRequestExternal", "runtime.onMessageExternal", "runtime.onMessageExternal"); }
160 | get inIncognitoContext() { return bridgeLog.DoActionAndLog(() => { return myBrowser.extension["inPrivateContext"]; }, "extension.inIncognitoContext", undefined, "extension.inPrivateContext"); }
161 | get lastError() { return bridgeLog.DoActionAndLog(() => { return myBrowser.runtime.lastError; }, "extension.lastError", undefined, "runtime.lastError"); }
162 | connect(extensionId, connectInfo) {
163 | return bridgeLog.DoActionAndLog(() => {
164 | return EdgeRuntimeBridge.prototype.connect(extensionId, connectInfo);
165 | }, "extension.connect", "runtime.connect", "runtime.connect");
166 | }
167 | sendMessage(message, responseCallback) {
168 | return bridgeLog.DoActionAndLog(() => {
169 | return EdgeRuntimeBridge.prototype.sendMessage(message, responseCallback, undefined, undefined);
170 | }, "extension.sendMessage", "runtime.sendMessage", "runtime.sendMessage");
171 | }
172 | sendRequest(extensionId, message, options, responseCallback) {
173 | return bridgeLog.DoActionAndLog(() => {
174 | return EdgeRuntimeBridge.prototype.sendMessage(extensionId, message, options, responseCallback);
175 | }, "extension.sendRequest", "runtime.sendMessage", "runtime.sendMessage");
176 | }
177 | isAllowedFileSchemeAccess(callback) {
178 | bridgeLog.LogUnavailbleApi("extension.isAllowedFileSchemeAccess");
179 | }
180 | isAllowedIncognitoAccess(callback) {
181 | bridgeLog.LogUnavailbleApi("extension.isAllowedIncognitoAccess");
182 | }
183 | setUpdateUrlData(data) {
184 | bridgeLog.LogUnavailbleApi("extension.setUpdateUrlData");
185 | }
186 | }
187 | class EdgeI18nBridge {
188 | getAcceptLanguages(callback) {
189 | return bridgeLog.DoActionAndLog(() => {
190 | return myBrowser.i18n.getAcceptLanguages(callback);
191 | }, "i18n.getAcceptLanguages");
192 | }
193 | getMessage(messageName, substitutions) {
194 | return bridgeLog.DoActionAndLog(() => {
195 | if (messageName.indexOf("@@extension_id") > -1) {
196 | return myBrowser.runtime.id;
197 | }
198 | if (typeof substitutions !== "undefined" && typeof substitutions !== "null") {
199 | return myBrowser.i18n.getMessage(messageName, substitutions);
200 | }
201 | else {
202 | return myBrowser.i18n.getMessage(messageName);
203 | }
204 | }, "i18n.getMessage");
205 | }
206 | getUILanguage() {
207 | return bridgeLog.DoActionAndLog(() => {
208 | return myBrowser.i18n.getUILanguage();
209 | }, "i18n.getUILanguage");
210 | }
211 | }
212 | class EdgeRuntimeBridge {
213 | get id() { return bridgeLog.DoActionAndLog(() => { return myBrowser.runtime.id; }, "runtime.id"); }
214 | get lastError() { return bridgeLog.DoActionAndLog(() => { return myBrowser.runtime.lastError; }, "runtime.lastError"); }
215 | get onConnect() { return bridgeLog.DoActionAndLog(() => { return myBrowser.runtime.onConnect; }, "runtime.onConnect"); }
216 | get onInstalled() { return bridgeLog.DoActionAndLog(() => { return myBrowser.runtime.onInstalled; }, "runtime.onInstalled"); }
217 | get onMessage() { return bridgeLog.DoActionAndLog(() => { return myBrowser.runtime.onMessage; }, "runtime.onMessage"); }
218 | get onMessageExternal() { return bridgeLog.DoActionAndLog(() => { return myBrowser.runtime.onMessageExternal; }, "runtime.onMessageExternal"); }
219 | connect(extensionId, connectInfo) {
220 | return bridgeLog.DoActionAndLog(() => {
221 | if (typeof connectInfo !== "undefined" && typeof connectInfo !== "null") {
222 | return myBrowser.runtime.connect(extensionId, connectInfo);
223 | }
224 | else {
225 | return myBrowser.runtime.connect(extensionId);
226 | }
227 | }, "runtime.connect");
228 | }
229 | getBackgroundPage(callback) {
230 | bridgeLog.DoActionAndLog(() => {
231 | myBrowser.runtime.getBackgroundPage(callback);
232 | }, "runtime.getBackgroundPage");
233 | }
234 | getManifest() {
235 | return bridgeLog.DoActionAndLog(() => {
236 | return myBrowser.runtime.getManifest();
237 | }, "runtime.getManifest");
238 | }
239 | getURL(path) {
240 | return bridgeLog.DoActionAndLog(() => {
241 | return myBrowser.runtime.getURL(path);
242 | }, "runtime.getURL");
243 | }
244 | sendMessage(extensionId, message, options, responseCallback) {
245 | bridgeLog.DoActionAndLog(() => {
246 | if (typeof responseCallback !== "undefined" && typeof responseCallback !== "null") {
247 | myBrowser.runtime.sendMessage(extensionId, message, options, responseCallback);
248 | }
249 | else if (typeof options !== "undefined" && typeof options !== "null") {
250 | myBrowser.runtime.sendMessage(extensionId, message, options);
251 | }
252 | else if (typeof message !== "undefined" && typeof message !== "null") {
253 | myBrowser.runtime.sendMessage(extensionId, message);
254 | }
255 | else {
256 | myBrowser.runtime.sendMessage(undefined, extensionId);
257 | }
258 | }, "runtime.sendMessage");
259 | }
260 | }
261 | class EdgeChromeRuntimeBridge extends EdgeRuntimeBridge {
262 | get onConnectExternal() { bridgeLog.LogUnavailbleApi("runtime.onConnectExternal"); return bridgeHelper.fakeEvent; }
263 | get onRestartRequired() { bridgeLog.LogUnavailbleApi("runtime.onRestartRequired"); return bridgeHelper.fakeEvent; }
264 | get onStartup() { bridgeLog.LogUnavailbleApi("runtime.onStartup"); return bridgeHelper.fakeEvent; }
265 | get onSuspend() { bridgeLog.LogUnavailbleApi("runtime.onSuspend"); return bridgeHelper.fakeEvent; }
266 | get onSuspendCanceled() { bridgeLog.LogUnavailbleApi("runtime.onSuspendCanceled"); return bridgeHelper.fakeEvent; }
267 | get onUpdateAvailable() { bridgeLog.LogUnavailbleApi("runtime.onUpdateAvailable"); return bridgeHelper.fakeEvent; }
268 | openOptionsPage(callback) {
269 | bridgeLog.DoActionAndLog(() => {
270 | var optionsPage = myBrowser.runtime.getManifest()["options_page"];
271 | var optionsPageUrl = myBrowser.runtime.getURL(optionsPage);
272 | if (typeof callback !== "undefined" && typeof callback !== "null") {
273 | myBrowser.tabs.create({ url: optionsPageUrl }, callback);
274 | }
275 | else {
276 | myBrowser.tabs.create({ url: optionsPageUrl });
277 | }
278 | }, "runtime.openOptionsPage", undefined, "tabs.create({ url: optionsPageUrl })");
279 | }
280 | connectNative(application) {
281 | bridgeLog.LogUnavailbleApi("runtime.connectNative");
282 | return null;
283 | }
284 | getPackageDirectoryEntry(callback) {
285 | bridgeLog.LogUnavailbleApi("runtime.getPackageDirectoryEntry");
286 | }
287 | getPlatformInfo(callback) {
288 | bridgeLog.LogUnavailbleApi("runtime.getPlatformInfo");
289 | }
290 | reload() {
291 | bridgeLog.LogUnavailbleApi("runtime.reload");
292 | }
293 | requestUpdateCheck(callback) {
294 | bridgeLog.LogUnavailbleApi("runtime.requestUpdateCheck");
295 | }
296 | restart() {
297 | bridgeLog.LogUnavailbleApi("runtime.restart");
298 | }
299 | setUninstallURL(url, callback) {
300 | bridgeLog.LogUnavailbleApi("runtime.setUninstallURL");
301 | }
302 | sendNativeMessage(application, message, responseCallback) {
303 | bridgeLog.LogUnavailbleApi("runtime.sendNativeMessage");
304 | }
305 | }
306 | class EdgeStorageBridge {
307 | get local() { return bridgeLog.DoActionAndLog(() => { return myBrowser.storage.local; }, "storage.local"); }
308 | get onChanged() { return bridgeLog.DoActionAndLog(() => { return myBrowser.storage.onChanged; }, "storage.onChanged"); }
309 | }
310 | class EdgeChromeStorageBridge extends EdgeStorageBridge {
311 | get managed() { return bridgeLog.DoActionAndLog(() => { return myBrowser.storage.local; }, "storage.managed", undefined, "storage.local"); }
312 | get sync() { return bridgeLog.DoActionAndLog(() => { return myBrowser.storage.local; }, "storage.sync", undefined, "storage.local"); }
313 | }
314 | class EdgeContentBridge {
315 | constructor() {
316 | this.extension = typeof browser.extension !== "undefined" ? new EdgeChromeExtensionBridge() : undefined;
317 | this.i18n = typeof browser.i18n !== "undefined" ? new EdgeI18nBridge() : undefined;
318 | this.runtime = typeof browser.runtime !== "undefined" ? new EdgeChromeRuntimeBridge() : undefined;
319 | this.storage = typeof browser.storage !== "undefined" ? new EdgeChromeStorageBridge() : undefined;
320 | }
321 | }
322 | var myBrowser = browser;
323 | var chrome = new EdgeContentBridge();
324 |
--------------------------------------------------------------------------------
/userscript/dist/make-github-greater.user.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name Make GitHub Greater
3 | // @namespace https://justineo.github.io/
4 | // @version 1.0.1
5 | // @description Let's make GitHub greater.
6 | // @author Justineo(justice360@gmail.com)
7 | // @match https://github.com/*
8 | // @grant none
9 | // @updateURL https://justineo.github.io/make-github-greater/userscript/dist/make-github-greater.user.js
10 | // @icon https://justineo.github.io/make-github-greater/icon.png
11 | // ==/UserScript==
12 | function isInteractive(e){for(;e!==document.body;){if(e.matches(EXCLUDE))return!0;e=e.parentNode}return!1}function asap(e,t){function r(){document&&document.querySelector(e)&&(document.removeEventListener("DOMNodeInserted",r),document.removeEventListener("DOMContentLoaded",r),console.log(performance.now()),t())}"loading"!==document.readyState?r():(document.addEventListener("DOMNodeInserted",r),document.addEventListener("DOMContentLoaded",r))}function updateStyle(e){var t=e.contrastRatio(white)>e.contrastRatio(black)?"#fff":"#000",r=kolor(t);style.textContent="\n.header {\n background-color: "+e+";\n border-bottom: 1px solid "+kolor(r.fadeOut(.925))+";\n}\n\n.header-logo-invertocat,\n.header .header-search-wrapper {\n color: "+r+";\n}\n\n.header .header-search-wrapper {\n background-color: "+kolor(r.fadeOut(.875))+";\n}\n\n.header .header-search-wrapper.focus {\n background-color: "+kolor(r.fadeOut(.825))+";\n}\n\n.header-nav-link {\n color: "+kolor(r.fadeOut(.25))+";\n}\n\n.header .header-search-input::-webkit-input-placeholder {\n color: "+kolor(r.fadeOut(.25))+";\n}\n\n.header .header-search-input::-moz-placeholder {\n color: "+kolor(r.fadeOut(.25))+";\n}\n\n.header-logo-invertocat:hover,\n.header-nav-link:hover,\n.header-nav-link:focus {\n color: "+r+";\n}\n\n.header-nav-link:hover .dropdown-caret,\n.header-nav-link:focus .dropdown-caret {\n border-top-color: "+r+"\n}\n\n.header .header-search-scope {\n color: "+kolor(r.fadeOut(.25))+";\n border-right-color: "+e+";\n}\n\n.header .header-search-wrapper.focus .header-search-scope {\n color: "+r+";\n background-color: "+kolor(r.fadeOut(.925))+";\n border-right-color: "+e+";\n}\n\n.notification-indicator .mail-status {\n border-color: "+e+";\n}\n"}function load(){style=document.createElement("style"),document.body.appendChild(style),current&&updateStyle(kolor(current))}function init(){var e=document.querySelector(".header");if(e){var t=document.createElement("input");t.type="color",document.body.appendChild(t),t.style.cssText="position: absolute; top: -"+t.offsetHeight+"px; left: -"+t.offsetWidth+"px;",t.value=current,t.addEventListener("input",function(){var e=t.value;localStorage.setItem(ITEM_KEY,e),updateStyle(kolor(e))}),e.addEventListener("dblclick",function(e){var r=e.target;isInteractive(r)||t.click()})}}!function(e){function t(e,t){var r=Math.abs(G[e]-G[t]);if(1!==r&&5!==r)return!1;var a={h1:e,h2:t};return 0===e&&300===t?a.h1=360:0===t&&300===e&&(a.h2=360),a}function r(e){var r=e.split(/\s+/),a=r.length;if(a<1||a>2)return!1;var n=r[a-1].toLowerCase();if(!(n in R))return!1;var o=R[n];if(1===a)return o;var i,s,f=r[0].toLowerCase();if(f in R)return i=R[f],s=t(o,i),!!s&&(s.h1+s.h2)/2;if(f in B)return i=B[f],s=t(o,i),!!s&&s.h1+(s.h2-s.h1)/4;var c=f.match(/(\w+)\(\s*([^\)]+)\s*\)/i);if(!c)return!1;if(f=c[1],f in B){i=B[f],s=t(o,i);var h=q[I].parse(c[2]);return h===!1?h:!!s&&s.h1+(s.h2-s.h1)*h}return!1}function a(e){return H.clamp(e,this.range[0],this.range[1])}function n(e){return H.wrap(e,this.range[0],this.range[1])}function o(e){this.optional=!1,H.extend(this,e)}function i(){o.apply(this,arguments),this.dataType=T|I,this.cssType=T,this.range=[0,255],this.filter=a,this.initial=255}function s(){o.apply(this,arguments),this.dataType=F|I,this.cssType=F,this.range=[0,1],this.filter=a,this.initial=1}function f(){s.apply(this,arguments),this.cssType=I}function c(){o.apply(this,arguments),this.dataType=F|j,this.cssType=F,this.range=[0,360],this.filter=n,this.initial=0}function h(){return C(this)}function l(){for(var e=this.space(),t=V[e].channels,r=[],a=t.length,n=0;n=o?60*(n-o)/c+0:s===a&&n=n?60*(a-n)/f+0:i===r&&a1&&s[c]--;for(c in s)s[c]<1/6?f[c]=o+6*(n-o)*s[c]:1/6<=s[c]&&s[c]<.5?f[c]=n:.5<=s[c]&&s[c]<2/3?f[c]=o+6*(n-o)*(2/3-s[c]):f[c]=o,f[c]*=255;return C.rgba(f.r,f.g,f.b,a)}function y(){var e=this.h(),t=this.s(),r=this.l(),a=this.a();r*=2,t*=r<=1?r:2-r;var n=(r+t)/2,o=2*t/(r+t);return C.hsva(e,o,n,a)}function m(){var e,t=this.h(),r=this.s(),a=this.v(),n=this.a(),o=Math.floor(t/60),i=t/60-o,s=a*(1-r),f=a*(1-i*r),c=a*(1-(1-i)*r);switch(o){case 0:e=[a,c,s,n];break;case 1:e=[f,a,s,n];break;case 2:e=[s,a,c,n];break;case 3:e=[s,f,a,n];break;case 4:e=[c,s,a,n];break;case 5:e=[a,s,f,n];break;default:e=[0,0,0,n]}for(var h=e.length-1;h--;)e[h]*=255;return C.rgba(e)}function w(){var e=this.h(),t=this.s(),r=this.v(),a=this.a(),n=(2-t)*r,o=t*r;return o/=n<=1?n:2-n,o=o||0,n/=2,C.hsla(e,o,n,a)}function k(){var e=this.h(),t=this.s(),r=this.v(),a=this.a();return C.hwb(e,(1-t)*r,1-r,a)}function S(){var e=this.h(),t=this.w(),r=this.b(),a=this.a();return C.hsva(e,1-t/(1-r),1-r,a)}function M(){var e=this.s(),t=this.a();return C.rgba(e,e,e,t)}function L(){var e=this.c(),t=this.m(),r=this.y(),a=this.b(),n=1-Math.min(1,e*(1-a)+a),o=1-Math.min(1,t*(1-a)+a),i=1-Math.min(1,r*(1-a)+a);return C.rgba(255*n,255*o,255*i,this.a())}function A(e,t){if(e===t)return[];if(Y[e][t])return[t];var r=[e],a={};for(a[e]=[];r.length;){var n=r.shift();for(var o in Y[n])if(!a[o]&&(r.push(o),a[o]=a[n].concat([o]),o===t))return a[o]}return null}function x(e,t){var r;for(var a in q)if(r=q[a],r.flag&t.dataType){var n=r.parse(e);if(n!==!1)return r.flag===I&&(n*=Math.abs(t.range[1]-t.range[0])),t.filter(n)}return t.initial}var C,O={cssPrecision:"auto"},H={isNumber:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&isFinite(e)},isString:function(e){return"[object String]"===Object.prototype.toString.call(e)},typeOf:function(e){return Object.prototype.toString.call(e).slice(8,-1)},has:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},slice:function(e,t,r){return Array.prototype.slice.call(e,t,r)},swap:function(e,t,r){var a=e[t];e[t]=e[r],e[r]=a},shuffle:function(e){for(var t=e.length-1;t>0;t--){var r=Math.floor(Math.random()*(t+1));H.swap(e,t,r)}},map:function(e,t,r){for(var a=[],n=e.length;n--;)a[n]=t.call(r||e,e[n],n);return a},clamp:function(e,t,r){return t>r&&(r=t+r,t=r-t,r-=t),Math.min(r,Math.max(t,e))},wrap:function(e,t,r){var a;return t>r&&(r=t+r,t=r-t,r-=t),a=r-t,t+(e%a+a)%a},zeroFill:function(e,t){return e+="",t-=e.length,t>0?new Array(t+1).join("0")+e:e+""},random:function(e,t){return e===t?e:Math.random()*(t-e)+e},extend:function(e,t){for(var r in t)e[r]=t[r];return e}},E={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rebeccapurple:"#663399",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32",transparent:"rgba(0, 0, 0, 0)"},R={red:0,orange:30,yellow:60,green:120,blue:240,purple:300},B={reddish:0,orangish:30,yellowish:60,greenish:120,bluish:240,purplish:300},G={0:0,30:1,60:2,120:3,240:4,300:5},T=1,F=2,I=4,j=8,q={1:{flag:T,parse:function(e){switch(H.typeOf(e)){case"Number":e=Math.round(e);break;case"String":e=!!e.match(/^[\-+]?\d+$/i)&&parseInt(e,10);break;default:e=!1}return e},stringify:function(e){return Math.round(e)+""}},2:{flag:F,parse:function(e){switch(H.typeOf(e)){case"Number":break;case"String":e=!!e.match(/^[\-+]?\d+(?:\.\d+)?$|^[\-+]?\.\d+$/i)&&parseFloat(e);break;default:e=!1}return e},stringify:function(e){var t=O.cssPrecision;return"auto"===t?e+"":parseFloat(e.toFixed(t))+""}},4:{flag:I,parse:function(e){switch(H.typeOf(e)){case"String":e=!!e.match(/^[\-+]?\d+(?:\.\d+)?%$|^[\-+]?\.\d+%$/i)&&parseFloat(e)/100;break;default:e=!1}return e},stringify:function(e){var t=O.cssPrecision;return"auto"===t?100*e+"%":parseFloat((100*e).toFixed(t))+"%"}},8:{flag:j,parse:function(e){switch(H.typeOf(e)){case"String":e.match(/^[\-+]?\d+(?:\.\d+)?deg$|^[\-+]?\.\d+deg$/i)?e=parseFloat(e):(e=r(e))||(e=!1);break;default:e=!1}return e},stringify:function(e){var t=O.cssPrecision;return"auto"===t?e+"deg":parseFloat(e.toFixed(t))+"deg"}}};o.create=function(e,t,r,a){return new e(H.extend(a||{},{name:t,alias:r}))},i.prototype=new o,i.prototype.constructor=i,s.prototype=new o,s.prototype.constructor=s,f.prototype=new s,f.prototype.constructor=f,c.prototype=new o,c.prototype.constructor=c;var V={RGB:{channels:[o.create(i,"red","r"),o.create(i,"green","g"),o.create(i,"blue","b")],pattern:/rgb\(\s*([^,]+?)\s*,\s*([^,]+?)\s*,\s*([^\)]+?)\s*\)/i},RGBA:{channels:[o.create(i,"red","r"),o.create(i,"green","g"),o.create(i,"blue","b"),o.create(s,"alpha","a")],pattern:/rgba\(\s*([^,]+?)\s*,\s*([^,]+?)\s*,\s*([^,]+?)\s*,\s*([^\)]+?)\s*\)/i},HSL:{channels:[o.create(c,"hue","h"),o.create(f,"saturation","s"),o.create(f,"lightness","l")],pattern:/hsl\(\s*([^,]+?)\s*,\s*([^,]+?)\s*,\s*([^\)]+?)\s*\)/i},HSLA:{channels:[o.create(c,"hue","h"),o.create(f,"saturation","s"),o.create(f,"lightness","l"),o.create(s,"alpha","a")],pattern:/hsla\(\s*([^,]+?)\s*,\s*([^,]+?)\s*,\s*([^,]+?)\s*,\s*([^\)]+?)\s*\)/i},HSV:{channels:[o.create(c,"hue","h"),o.create(f,"saturation","s"),o.create(f,"value","v")],pattern:/hsv\(\s*([^,]+?)\s*,\s*([^,]+?)\s*,\s*([^\)]+?)\s*\)/i},HSVA:{channels:[o.create(c,"hue","h"),o.create(f,"saturation","s"),o.create(f,"value","v"),o.create(s,"alpha","a")],pattern:/hsva\(\s*([^,]+?)\s*,\s*([^,]+?)\s*,\s*([^,]+?)\s*,\s*([^\)]+?)\s*\)/i},HWB:{channels:[o.create(c,"hue","h"),o.create(f,"whiteness","w"),o.create(f,"blackness","b"),o.create(s,"alpha","a",{optional:!0})],pattern:/hwb\(\s*([^,]+?)\s*,\s*([^,]+?)\s*,\s*([^,\)]+?)(?:\s*,\s*([^\)]+?))?\s*\)/i},GRAY:{channels:[o.create(i,"shade","s"),o.create(s,"alpha","a")],pattern:/gray\(\s*([^,\)]+?)(?:\s*,\s*([^\)]+?))?\s*\)/i},CMYK:{channels:[o.create(s,"cyan","c"),o.create(s,"magenta","m"),o.create(s,"yellow","y"),o.create(s,"black",["b","k"]),o.create(s,"alpha","a",{optional:!0})],pattern:/(?:device-)?cmyk\(\s*([^,]+?)\s*,\s*([^,]+?)\s*,\s*([^,]+?)\s*,\s*([^,]+?)(?:\s*,\s*([^\)]+?))?\s*\)/i}},Y={RGB:{RGBA:l},RGBA:{RGB:u,HSLA:p,HSVA:g,GRAY:b,CMYK:d},HSL:{HSLA:l},HSLA:{HSL:u,HSVA:y,RGBA:v},HSV:{HSVA:l},HSVA:{HSV:u,RGBA:m,HSLA:w,HWB:k},HWB:{HSVA:S},GRAY:{RGBA:M},CMYK:{RGBA:L}};C=function(e){if(e._space&&H.has(C,e._space))return new C[e._space](e.toArray());if(H.has(E,e))return C(E[e.toLowerCase()]);var t,r=/^\s*#?([0-9a-f]{3}[0-9a-f]?|[0-9a-f]{6}(?:[0-9a-f]{2})?)\s*$/i;if(t=e.match(r)){var a=t[1];a.length<=4&&(a=H.map(a.split(""),function(e){return e+e}).join(""));var n=H.map(a.match(/\w{2}/g),function(e,t){var r=parseInt(e,16);return 3===t?100*r/255+"%":r}),o=4===n.length?"RGBA":"RGB";return new C[o](n)}for(var i in V)if(t=e.match(V[i].pattern)){var s=t.slice(1);return new C[i](s)}return!1};for(var _ in V){C[_.toLowerCase()]=function(e){return function(){var t=H.slice(arguments,0),r=H.typeOf(t[0]);return"Array"!==r&&"Object"!==r||(t=t[0]),new C[e](t)}}(_);var $=V[_],N=$.channels;C[_]=function(e){return function(t){var r=V[e].channels,a=r.length;t=null==t?[]:t,this._space=e;for(var n=a;n--;){var o,i=r[n],s=i.name,f=i.alias;if(null!=t[n])o=t[n];else if(H.has(t,s))o=t[s];else{f=H.isString(f)?[f]:f;for(var c=0,h=f.length;c': '>',
64 | '"': '"',
65 | "'": ''',
66 | '/': '/'
67 | };
68 |
69 | function escapeHtml (string) {
70 | return String(string).replace(/[&<>"'\/]/g, function fromEntityMap (s) {
71 | return entityMap[s];
72 | });
73 | }
74 |
75 | var whiteRe = /\s*/;
76 | var spaceRe = /\s+/;
77 | var equalsRe = /\s*=/;
78 | var curlyRe = /\s*\}/;
79 | var tagRe = /#|\^|\/|>|\{|&|=|!/;
80 |
81 | /**
82 | * Breaks up the given `template` string into a tree of tokens. If the `tags`
83 | * argument is given here it must be an array with two string values: the
84 | * opening and closing tags used in the template (e.g. [ "<%", "%>" ]). Of
85 | * course, the default is to use mustaches (i.e. mustache.tags).
86 | *
87 | * A token is an array with at least 4 elements. The first element is the
88 | * mustache symbol that was used inside the tag, e.g. "#" or "&". If the tag
89 | * did not contain a symbol (i.e. {{myValue}}) this element is "name". For
90 | * all text that appears outside a symbol this element is "text".
91 | *
92 | * The second element of a token is its "value". For mustache tags this is
93 | * whatever else was inside the tag besides the opening symbol. For text tokens
94 | * this is the text itself.
95 | *
96 | * The third and fourth elements of the token are the start and end indices,
97 | * respectively, of the token in the original template.
98 | *
99 | * Tokens that are the root node of a subtree contain two more elements: 1) an
100 | * array of tokens in the subtree and 2) the index in the original template at
101 | * which the closing tag for that section begins.
102 | */
103 | function parseTemplate (template, tags) {
104 | if (!template)
105 | return [];
106 |
107 | var sections = []; // Stack to hold section tokens
108 | var tokens = []; // Buffer to hold the tokens
109 | var spaces = []; // Indices of whitespace tokens on the current line
110 | var hasTag = false; // Is there a {{tag}} on the current line?
111 | var nonSpace = false; // Is there a non-space char on the current line?
112 |
113 | // Strips all whitespace tokens array for the current line
114 | // if there was a {{#tag}} on it and otherwise only space.
115 | function stripSpace () {
116 | if (hasTag && !nonSpace) {
117 | while (spaces.length)
118 | delete tokens[spaces.pop()];
119 | } else {
120 | spaces = [];
121 | }
122 |
123 | hasTag = false;
124 | nonSpace = false;
125 | }
126 |
127 | var openingTagRe, closingTagRe, closingCurlyRe;
128 | function compileTags (tagsToCompile) {
129 | if (typeof tagsToCompile === 'string')
130 | tagsToCompile = tagsToCompile.split(spaceRe, 2);
131 |
132 | if (!isArray(tagsToCompile) || tagsToCompile.length !== 2)
133 | throw new Error('Invalid tags: ' + tagsToCompile);
134 |
135 | openingTagRe = new RegExp(escapeRegExp(tagsToCompile[0]) + '\\s*');
136 | closingTagRe = new RegExp('\\s*' + escapeRegExp(tagsToCompile[1]));
137 | closingCurlyRe = new RegExp('\\s*' + escapeRegExp('}' + tagsToCompile[1]));
138 | }
139 |
140 | compileTags(tags || mustache.tags);
141 |
142 | var scanner = new Scanner(template);
143 |
144 | var start, type, value, chr, token, openSection;
145 | while (!scanner.eos()) {
146 | start = scanner.pos;
147 |
148 | // Match any text between tags.
149 | value = scanner.scanUntil(openingTagRe);
150 |
151 | if (value) {
152 | for (var i = 0, valueLength = value.length; i < valueLength; ++i) {
153 | chr = value.charAt(i);
154 |
155 | if (isWhitespace(chr)) {
156 | spaces.push(tokens.length);
157 | } else {
158 | nonSpace = true;
159 | }
160 |
161 | tokens.push([ 'text', chr, start, start + 1 ]);
162 | start += 1;
163 |
164 | // Check for whitespace on the current line.
165 | if (chr === '\n')
166 | stripSpace();
167 | }
168 | }
169 |
170 | // Match the opening tag.
171 | if (!scanner.scan(openingTagRe))
172 | break;
173 |
174 | hasTag = true;
175 |
176 | // Get the tag type.
177 | type = scanner.scan(tagRe) || 'name';
178 | scanner.scan(whiteRe);
179 |
180 | // Get the tag value.
181 | if (type === '=') {
182 | value = scanner.scanUntil(equalsRe);
183 | scanner.scan(equalsRe);
184 | scanner.scanUntil(closingTagRe);
185 | } else if (type === '{') {
186 | value = scanner.scanUntil(closingCurlyRe);
187 | scanner.scan(curlyRe);
188 | scanner.scanUntil(closingTagRe);
189 | type = '&';
190 | } else {
191 | value = scanner.scanUntil(closingTagRe);
192 | }
193 |
194 | // Match the closing tag.
195 | if (!scanner.scan(closingTagRe))
196 | throw new Error('Unclosed tag at ' + scanner.pos);
197 |
198 | token = [ type, value, start, scanner.pos ];
199 | tokens.push(token);
200 |
201 | if (type === '#' || type === '^') {
202 | sections.push(token);
203 | } else if (type === '/') {
204 | // Check section nesting.
205 | openSection = sections.pop();
206 |
207 | if (!openSection)
208 | throw new Error('Unopened section "' + value + '" at ' + start);
209 |
210 | if (openSection[1] !== value)
211 | throw new Error('Unclosed section "' + openSection[1] + '" at ' + start);
212 | } else if (type === 'name' || type === '{' || type === '&') {
213 | nonSpace = true;
214 | } else if (type === '=') {
215 | // Set the tags for the next time around.
216 | compileTags(value);
217 | }
218 | }
219 |
220 | // Make sure there are no open sections when we're done.
221 | openSection = sections.pop();
222 |
223 | if (openSection)
224 | throw new Error('Unclosed section "' + openSection[1] + '" at ' + scanner.pos);
225 |
226 | return nestTokens(squashTokens(tokens));
227 | }
228 |
229 | /**
230 | * Combines the values of consecutive text tokens in the given `tokens` array
231 | * to a single token.
232 | */
233 | function squashTokens (tokens) {
234 | var squashedTokens = [];
235 |
236 | var token, lastToken;
237 | for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
238 | token = tokens[i];
239 |
240 | if (token) {
241 | if (token[0] === 'text' && lastToken && lastToken[0] === 'text') {
242 | lastToken[1] += token[1];
243 | lastToken[3] = token[3];
244 | } else {
245 | squashedTokens.push(token);
246 | lastToken = token;
247 | }
248 | }
249 | }
250 |
251 | return squashedTokens;
252 | }
253 |
254 | /**
255 | * Forms the given array of `tokens` into a nested tree structure where
256 | * tokens that represent a section have two additional items: 1) an array of
257 | * all tokens that appear in that section and 2) the index in the original
258 | * template that represents the end of that section.
259 | */
260 | function nestTokens (tokens) {
261 | var nestedTokens = [];
262 | var collector = nestedTokens;
263 | var sections = [];
264 |
265 | var token, section;
266 | for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
267 | token = tokens[i];
268 |
269 | switch (token[0]) {
270 | case '#':
271 | case '^':
272 | collector.push(token);
273 | sections.push(token);
274 | collector = token[4] = [];
275 | break;
276 | case '/':
277 | section = sections.pop();
278 | section[5] = token[2];
279 | collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens;
280 | break;
281 | default:
282 | collector.push(token);
283 | }
284 | }
285 |
286 | return nestedTokens;
287 | }
288 |
289 | /**
290 | * A simple string scanner that is used by the template parser to find
291 | * tokens in template strings.
292 | */
293 | function Scanner (string) {
294 | this.string = string;
295 | this.tail = string;
296 | this.pos = 0;
297 | }
298 |
299 | /**
300 | * Returns `true` if the tail is empty (end of string).
301 | */
302 | Scanner.prototype.eos = function eos () {
303 | return this.tail === '';
304 | };
305 |
306 | /**
307 | * Tries to match the given regular expression at the current position.
308 | * Returns the matched text if it can match, the empty string otherwise.
309 | */
310 | Scanner.prototype.scan = function scan (re) {
311 | var match = this.tail.match(re);
312 |
313 | if (!match || match.index !== 0)
314 | return '';
315 |
316 | var string = match[0];
317 |
318 | this.tail = this.tail.substring(string.length);
319 | this.pos += string.length;
320 |
321 | return string;
322 | };
323 |
324 | /**
325 | * Skips all text until the given regular expression can be matched. Returns
326 | * the skipped string, which is the entire tail if no match can be made.
327 | */
328 | Scanner.prototype.scanUntil = function scanUntil (re) {
329 | var index = this.tail.search(re), match;
330 |
331 | switch (index) {
332 | case -1:
333 | match = this.tail;
334 | this.tail = '';
335 | break;
336 | case 0:
337 | match = '';
338 | break;
339 | default:
340 | match = this.tail.substring(0, index);
341 | this.tail = this.tail.substring(index);
342 | }
343 |
344 | this.pos += match.length;
345 |
346 | return match;
347 | };
348 |
349 | /**
350 | * Represents a rendering context by wrapping a view object and
351 | * maintaining a reference to the parent context.
352 | */
353 | function Context (view, parentContext) {
354 | this.view = view;
355 | this.cache = { '.': this.view };
356 | this.parent = parentContext;
357 | }
358 |
359 | /**
360 | * Creates a new context using the given view with this context
361 | * as the parent.
362 | */
363 | Context.prototype.push = function push (view) {
364 | return new Context(view, this);
365 | };
366 |
367 | /**
368 | * Returns the value of the given name in this context, traversing
369 | * up the context hierarchy if the value is absent in this context's view.
370 | */
371 | Context.prototype.lookup = function lookup (name) {
372 | var cache = this.cache;
373 |
374 | var value;
375 | if (cache.hasOwnProperty(name)) {
376 | value = cache[name];
377 | } else {
378 | var context = this, names, index, lookupHit = false;
379 |
380 | while (context) {
381 | if (name.indexOf('.') > 0) {
382 | value = context.view;
383 | names = name.split('.');
384 | index = 0;
385 |
386 | /**
387 | * Using the dot notion path in `name`, we descend through the
388 | * nested objects.
389 | *
390 | * To be certain that the lookup has been successful, we have to
391 | * check if the last object in the path actually has the property
392 | * we are looking for. We store the result in `lookupHit`.
393 | *
394 | * This is specially necessary for when the value has been set to
395 | * `undefined` and we want to avoid looking up parent contexts.
396 | **/
397 | while (value != null && index < names.length) {
398 | if (index === names.length - 1)
399 | lookupHit = hasProperty(value, names[index]);
400 |
401 | value = value[names[index++]];
402 | }
403 | } else {
404 | value = context.view[name];
405 | lookupHit = hasProperty(context.view, name);
406 | }
407 |
408 | if (lookupHit)
409 | break;
410 |
411 | context = context.parent;
412 | }
413 |
414 | cache[name] = value;
415 | }
416 |
417 | if (isFunction(value))
418 | value = value.call(this.view);
419 |
420 | return value;
421 | };
422 |
423 | /**
424 | * A Writer knows how to take a stream of tokens and render them to a
425 | * string, given a context. It also maintains a cache of templates to
426 | * avoid the need to parse the same template twice.
427 | */
428 | function Writer () {
429 | this.cache = {};
430 | }
431 |
432 | /**
433 | * Clears all cached templates in this writer.
434 | */
435 | Writer.prototype.clearCache = function clearCache () {
436 | this.cache = {};
437 | };
438 |
439 | /**
440 | * Parses and caches the given `template` and returns the array of tokens
441 | * that is generated from the parse.
442 | */
443 | Writer.prototype.parse = function parse (template, tags) {
444 | var cache = this.cache;
445 | var tokens = cache[template];
446 |
447 | if (tokens == null)
448 | tokens = cache[template] = parseTemplate(template, tags);
449 |
450 | return tokens;
451 | };
452 |
453 | /**
454 | * High-level method that is used to render the given `template` with
455 | * the given `view`.
456 | *
457 | * The optional `partials` argument may be an object that contains the
458 | * names and templates of partials that are used in the template. It may
459 | * also be a function that is used to load partial templates on the fly
460 | * that takes a single argument: the name of the partial.
461 | */
462 | Writer.prototype.render = function render (template, view, partials) {
463 | var tokens = this.parse(template);
464 | var context = (view instanceof Context) ? view : new Context(view);
465 | return this.renderTokens(tokens, context, partials, template);
466 | };
467 |
468 | /**
469 | * Low-level method that renders the given array of `tokens` using
470 | * the given `context` and `partials`.
471 | *
472 | * Note: The `originalTemplate` is only ever used to extract the portion
473 | * of the original template that was contained in a higher-order section.
474 | * If the template doesn't use higher-order sections, this argument may
475 | * be omitted.
476 | */
477 | Writer.prototype.renderTokens = function renderTokens (tokens, context, partials, originalTemplate) {
478 | var buffer = '';
479 |
480 | var token, symbol, value;
481 | for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
482 | value = undefined;
483 | token = tokens[i];
484 | symbol = token[0];
485 |
486 | if (symbol === '#') value = this.renderSection(token, context, partials, originalTemplate);
487 | else if (symbol === '^') value = this.renderInverted(token, context, partials, originalTemplate);
488 | else if (symbol === '>') value = this.renderPartial(token, context, partials, originalTemplate);
489 | else if (symbol === '&') value = this.unescapedValue(token, context);
490 | else if (symbol === 'name') value = this.escapedValue(token, context);
491 | else if (symbol === 'text') value = this.rawValue(token);
492 |
493 | if (value !== undefined)
494 | buffer += value;
495 | }
496 |
497 | return buffer;
498 | };
499 |
500 | Writer.prototype.renderSection = function renderSection (token, context, partials, originalTemplate) {
501 | var self = this;
502 | var buffer = '';
503 | var value = context.lookup(token[1]);
504 |
505 | // This function is used to render an arbitrary template
506 | // in the current context by higher-order sections.
507 | function subRender (template) {
508 | return self.render(template, context, partials);
509 | }
510 |
511 | if (!value) return;
512 |
513 | if (isArray(value)) {
514 | for (var j = 0, valueLength = value.length; j < valueLength; ++j) {
515 | buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate);
516 | }
517 | } else if (typeof value === 'object' || typeof value === 'string' || typeof value === 'number') {
518 | buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate);
519 | } else if (isFunction(value)) {
520 | if (typeof originalTemplate !== 'string')
521 | throw new Error('Cannot use higher-order sections without the original template');
522 |
523 | // Extract the portion of the original template that the section contains.
524 | value = value.call(context.view, originalTemplate.slice(token[3], token[5]), subRender);
525 |
526 | if (value != null)
527 | buffer += value;
528 | } else {
529 | buffer += this.renderTokens(token[4], context, partials, originalTemplate);
530 | }
531 | return buffer;
532 | };
533 |
534 | Writer.prototype.renderInverted = function renderInverted (token, context, partials, originalTemplate) {
535 | var value = context.lookup(token[1]);
536 |
537 | // Use JavaScript's definition of falsy. Include empty arrays.
538 | // See https://github.com/janl/mustache.js/issues/186
539 | if (!value || (isArray(value) && value.length === 0))
540 | return this.renderTokens(token[4], context, partials, originalTemplate);
541 | };
542 |
543 | Writer.prototype.renderPartial = function renderPartial (token, context, partials) {
544 | if (!partials) return;
545 |
546 | var value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
547 | if (value != null)
548 | return this.renderTokens(this.parse(value), context, partials, value);
549 | };
550 |
551 | Writer.prototype.unescapedValue = function unescapedValue (token, context) {
552 | var value = context.lookup(token[1]);
553 | if (value != null)
554 | return value;
555 | };
556 |
557 | Writer.prototype.escapedValue = function escapedValue (token, context) {
558 | var value = context.lookup(token[1]);
559 | if (value != null)
560 | return mustache.escape(value);
561 | };
562 |
563 | Writer.prototype.rawValue = function rawValue (token) {
564 | return token[1];
565 | };
566 |
567 | mustache.name = 'mustache.js';
568 | mustache.version = '2.1.3';
569 | mustache.tags = [ '{{', '}}' ];
570 |
571 | // All high-level mustache.* functions use this writer.
572 | var defaultWriter = new Writer();
573 |
574 | /**
575 | * Clears all cached templates in the default writer.
576 | */
577 | mustache.clearCache = function clearCache () {
578 | return defaultWriter.clearCache();
579 | };
580 |
581 | /**
582 | * Parses and caches the given template in the default writer and returns the
583 | * array of tokens it contains. Doing this ahead of time avoids the need to
584 | * parse templates on the fly as they are rendered.
585 | */
586 | mustache.parse = function parse (template, tags) {
587 | return defaultWriter.parse(template, tags);
588 | };
589 |
590 | /**
591 | * Renders the `template` with the given `view` and `partials` using the
592 | * default writer.
593 | */
594 | mustache.render = function render (template, view, partials) {
595 | if (typeof template !== 'string') {
596 | throw new TypeError('Invalid template! Template should be a "string" ' +
597 | 'but "' + typeStr(template) + '" was given as the first ' +
598 | 'argument for mustache#render(template, view, partials)');
599 | }
600 |
601 | return defaultWriter.render(template, view, partials);
602 | };
603 |
604 | // This is here for backwards compatibility with 0.4.x.,
605 | /*eslint-disable */ // eslint wants camel cased function name
606 | mustache.to_html = function to_html (template, view, partials, send) {
607 | /*eslint-enable*/
608 |
609 | var result = mustache.render(template, view, partials);
610 |
611 | if (isFunction(send)) {
612 | send(result);
613 | } else {
614 | return result;
615 | }
616 | };
617 |
618 | // Export the escaping function so that the user may override it.
619 | // See https://github.com/janl/mustache.js/issues/244
620 | mustache.escape = escapeHtml;
621 |
622 | // Export these mainly for testing, but also for advanced usage.
623 | mustache.Scanner = Scanner;
624 | mustache.Context = Context;
625 | mustache.Writer = Writer;
626 |
627 | }));
628 |
--------------------------------------------------------------------------------
/extensions/edge/mustache.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * mustache.js - Logic-less {{mustache}} templates with JavaScript
3 | * http://github.com/janl/mustache.js
4 | */
5 |
6 | /*global define: false Mustache: true*/
7 |
8 | (function defineMustache (global, factory) {
9 | if (typeof exports === 'object' && exports && typeof exports.nodeName !== 'string') {
10 | factory(exports); // CommonJS
11 | } else if (typeof define === 'function' && define.amd) {
12 | define(['exports'], factory); // AMD
13 | } else {
14 | global.Mustache = {};
15 | factory(Mustache); // script, wsh, asp
16 | }
17 | }(this, function mustacheFactory (mustache) {
18 |
19 | var objectToString = Object.prototype.toString;
20 | var isArray = Array.isArray || function isArrayPolyfill (object) {
21 | return objectToString.call(object) === '[object Array]';
22 | };
23 |
24 | function isFunction (object) {
25 | return typeof object === 'function';
26 | }
27 |
28 | /**
29 | * More correct typeof string handling array
30 | * which normally returns typeof 'object'
31 | */
32 | function typeStr (obj) {
33 | return isArray(obj) ? 'array' : typeof obj;
34 | }
35 |
36 | function escapeRegExp (string) {
37 | return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
38 | }
39 |
40 | /**
41 | * Null safe way of checking whether or not an object,
42 | * including its prototype, has a given property
43 | */
44 | function hasProperty (obj, propName) {
45 | return obj != null && typeof obj === 'object' && (propName in obj);
46 | }
47 |
48 | // Workaround for https://issues.apache.org/jira/browse/COUCHDB-577
49 | // See https://github.com/janl/mustache.js/issues/189
50 | var regExpTest = RegExp.prototype.test;
51 | function testRegExp (re, string) {
52 | return regExpTest.call(re, string);
53 | }
54 |
55 | var nonSpaceRe = /\S/;
56 | function isWhitespace (string) {
57 | return !testRegExp(nonSpaceRe, string);
58 | }
59 |
60 | var entityMap = {
61 | '&': '&',
62 | '<': '<',
63 | '>': '>',
64 | '"': '"',
65 | "'": ''',
66 | '/': '/'
67 | };
68 |
69 | function escapeHtml (string) {
70 | return String(string).replace(/[&<>"'\/]/g, function fromEntityMap (s) {
71 | return entityMap[s];
72 | });
73 | }
74 |
75 | var whiteRe = /\s*/;
76 | var spaceRe = /\s+/;
77 | var equalsRe = /\s*=/;
78 | var curlyRe = /\s*\}/;
79 | var tagRe = /#|\^|\/|>|\{|&|=|!/;
80 |
81 | /**
82 | * Breaks up the given `template` string into a tree of tokens. If the `tags`
83 | * argument is given here it must be an array with two string values: the
84 | * opening and closing tags used in the template (e.g. [ "<%", "%>" ]). Of
85 | * course, the default is to use mustaches (i.e. mustache.tags).
86 | *
87 | * A token is an array with at least 4 elements. The first element is the
88 | * mustache symbol that was used inside the tag, e.g. "#" or "&". If the tag
89 | * did not contain a symbol (i.e. {{myValue}}) this element is "name". For
90 | * all text that appears outside a symbol this element is "text".
91 | *
92 | * The second element of a token is its "value". For mustache tags this is
93 | * whatever else was inside the tag besides the opening symbol. For text tokens
94 | * this is the text itself.
95 | *
96 | * The third and fourth elements of the token are the start and end indices,
97 | * respectively, of the token in the original template.
98 | *
99 | * Tokens that are the root node of a subtree contain two more elements: 1) an
100 | * array of tokens in the subtree and 2) the index in the original template at
101 | * which the closing tag for that section begins.
102 | */
103 | function parseTemplate (template, tags) {
104 | if (!template)
105 | return [];
106 |
107 | var sections = []; // Stack to hold section tokens
108 | var tokens = []; // Buffer to hold the tokens
109 | var spaces = []; // Indices of whitespace tokens on the current line
110 | var hasTag = false; // Is there a {{tag}} on the current line?
111 | var nonSpace = false; // Is there a non-space char on the current line?
112 |
113 | // Strips all whitespace tokens array for the current line
114 | // if there was a {{#tag}} on it and otherwise only space.
115 | function stripSpace () {
116 | if (hasTag && !nonSpace) {
117 | while (spaces.length)
118 | delete tokens[spaces.pop()];
119 | } else {
120 | spaces = [];
121 | }
122 |
123 | hasTag = false;
124 | nonSpace = false;
125 | }
126 |
127 | var openingTagRe, closingTagRe, closingCurlyRe;
128 | function compileTags (tagsToCompile) {
129 | if (typeof tagsToCompile === 'string')
130 | tagsToCompile = tagsToCompile.split(spaceRe, 2);
131 |
132 | if (!isArray(tagsToCompile) || tagsToCompile.length !== 2)
133 | throw new Error('Invalid tags: ' + tagsToCompile);
134 |
135 | openingTagRe = new RegExp(escapeRegExp(tagsToCompile[0]) + '\\s*');
136 | closingTagRe = new RegExp('\\s*' + escapeRegExp(tagsToCompile[1]));
137 | closingCurlyRe = new RegExp('\\s*' + escapeRegExp('}' + tagsToCompile[1]));
138 | }
139 |
140 | compileTags(tags || mustache.tags);
141 |
142 | var scanner = new Scanner(template);
143 |
144 | var start, type, value, chr, token, openSection;
145 | while (!scanner.eos()) {
146 | start = scanner.pos;
147 |
148 | // Match any text between tags.
149 | value = scanner.scanUntil(openingTagRe);
150 |
151 | if (value) {
152 | for (var i = 0, valueLength = value.length; i < valueLength; ++i) {
153 | chr = value.charAt(i);
154 |
155 | if (isWhitespace(chr)) {
156 | spaces.push(tokens.length);
157 | } else {
158 | nonSpace = true;
159 | }
160 |
161 | tokens.push([ 'text', chr, start, start + 1 ]);
162 | start += 1;
163 |
164 | // Check for whitespace on the current line.
165 | if (chr === '\n')
166 | stripSpace();
167 | }
168 | }
169 |
170 | // Match the opening tag.
171 | if (!scanner.scan(openingTagRe))
172 | break;
173 |
174 | hasTag = true;
175 |
176 | // Get the tag type.
177 | type = scanner.scan(tagRe) || 'name';
178 | scanner.scan(whiteRe);
179 |
180 | // Get the tag value.
181 | if (type === '=') {
182 | value = scanner.scanUntil(equalsRe);
183 | scanner.scan(equalsRe);
184 | scanner.scanUntil(closingTagRe);
185 | } else if (type === '{') {
186 | value = scanner.scanUntil(closingCurlyRe);
187 | scanner.scan(curlyRe);
188 | scanner.scanUntil(closingTagRe);
189 | type = '&';
190 | } else {
191 | value = scanner.scanUntil(closingTagRe);
192 | }
193 |
194 | // Match the closing tag.
195 | if (!scanner.scan(closingTagRe))
196 | throw new Error('Unclosed tag at ' + scanner.pos);
197 |
198 | token = [ type, value, start, scanner.pos ];
199 | tokens.push(token);
200 |
201 | if (type === '#' || type === '^') {
202 | sections.push(token);
203 | } else if (type === '/') {
204 | // Check section nesting.
205 | openSection = sections.pop();
206 |
207 | if (!openSection)
208 | throw new Error('Unopened section "' + value + '" at ' + start);
209 |
210 | if (openSection[1] !== value)
211 | throw new Error('Unclosed section "' + openSection[1] + '" at ' + start);
212 | } else if (type === 'name' || type === '{' || type === '&') {
213 | nonSpace = true;
214 | } else if (type === '=') {
215 | // Set the tags for the next time around.
216 | compileTags(value);
217 | }
218 | }
219 |
220 | // Make sure there are no open sections when we're done.
221 | openSection = sections.pop();
222 |
223 | if (openSection)
224 | throw new Error('Unclosed section "' + openSection[1] + '" at ' + scanner.pos);
225 |
226 | return nestTokens(squashTokens(tokens));
227 | }
228 |
229 | /**
230 | * Combines the values of consecutive text tokens in the given `tokens` array
231 | * to a single token.
232 | */
233 | function squashTokens (tokens) {
234 | var squashedTokens = [];
235 |
236 | var token, lastToken;
237 | for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
238 | token = tokens[i];
239 |
240 | if (token) {
241 | if (token[0] === 'text' && lastToken && lastToken[0] === 'text') {
242 | lastToken[1] += token[1];
243 | lastToken[3] = token[3];
244 | } else {
245 | squashedTokens.push(token);
246 | lastToken = token;
247 | }
248 | }
249 | }
250 |
251 | return squashedTokens;
252 | }
253 |
254 | /**
255 | * Forms the given array of `tokens` into a nested tree structure where
256 | * tokens that represent a section have two additional items: 1) an array of
257 | * all tokens that appear in that section and 2) the index in the original
258 | * template that represents the end of that section.
259 | */
260 | function nestTokens (tokens) {
261 | var nestedTokens = [];
262 | var collector = nestedTokens;
263 | var sections = [];
264 |
265 | var token, section;
266 | for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
267 | token = tokens[i];
268 |
269 | switch (token[0]) {
270 | case '#':
271 | case '^':
272 | collector.push(token);
273 | sections.push(token);
274 | collector = token[4] = [];
275 | break;
276 | case '/':
277 | section = sections.pop();
278 | section[5] = token[2];
279 | collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens;
280 | break;
281 | default:
282 | collector.push(token);
283 | }
284 | }
285 |
286 | return nestedTokens;
287 | }
288 |
289 | /**
290 | * A simple string scanner that is used by the template parser to find
291 | * tokens in template strings.
292 | */
293 | function Scanner (string) {
294 | this.string = string;
295 | this.tail = string;
296 | this.pos = 0;
297 | }
298 |
299 | /**
300 | * Returns `true` if the tail is empty (end of string).
301 | */
302 | Scanner.prototype.eos = function eos () {
303 | return this.tail === '';
304 | };
305 |
306 | /**
307 | * Tries to match the given regular expression at the current position.
308 | * Returns the matched text if it can match, the empty string otherwise.
309 | */
310 | Scanner.prototype.scan = function scan (re) {
311 | var match = this.tail.match(re);
312 |
313 | if (!match || match.index !== 0)
314 | return '';
315 |
316 | var string = match[0];
317 |
318 | this.tail = this.tail.substring(string.length);
319 | this.pos += string.length;
320 |
321 | return string;
322 | };
323 |
324 | /**
325 | * Skips all text until the given regular expression can be matched. Returns
326 | * the skipped string, which is the entire tail if no match can be made.
327 | */
328 | Scanner.prototype.scanUntil = function scanUntil (re) {
329 | var index = this.tail.search(re), match;
330 |
331 | switch (index) {
332 | case -1:
333 | match = this.tail;
334 | this.tail = '';
335 | break;
336 | case 0:
337 | match = '';
338 | break;
339 | default:
340 | match = this.tail.substring(0, index);
341 | this.tail = this.tail.substring(index);
342 | }
343 |
344 | this.pos += match.length;
345 |
346 | return match;
347 | };
348 |
349 | /**
350 | * Represents a rendering context by wrapping a view object and
351 | * maintaining a reference to the parent context.
352 | */
353 | function Context (view, parentContext) {
354 | this.view = view;
355 | this.cache = { '.': this.view };
356 | this.parent = parentContext;
357 | }
358 |
359 | /**
360 | * Creates a new context using the given view with this context
361 | * as the parent.
362 | */
363 | Context.prototype.push = function push (view) {
364 | return new Context(view, this);
365 | };
366 |
367 | /**
368 | * Returns the value of the given name in this context, traversing
369 | * up the context hierarchy if the value is absent in this context's view.
370 | */
371 | Context.prototype.lookup = function lookup (name) {
372 | var cache = this.cache;
373 |
374 | var value;
375 | if (cache.hasOwnProperty(name)) {
376 | value = cache[name];
377 | } else {
378 | var context = this, names, index, lookupHit = false;
379 |
380 | while (context) {
381 | if (name.indexOf('.') > 0) {
382 | value = context.view;
383 | names = name.split('.');
384 | index = 0;
385 |
386 | /**
387 | * Using the dot notion path in `name`, we descend through the
388 | * nested objects.
389 | *
390 | * To be certain that the lookup has been successful, we have to
391 | * check if the last object in the path actually has the property
392 | * we are looking for. We store the result in `lookupHit`.
393 | *
394 | * This is specially necessary for when the value has been set to
395 | * `undefined` and we want to avoid looking up parent contexts.
396 | **/
397 | while (value != null && index < names.length) {
398 | if (index === names.length - 1)
399 | lookupHit = hasProperty(value, names[index]);
400 |
401 | value = value[names[index++]];
402 | }
403 | } else {
404 | value = context.view[name];
405 | lookupHit = hasProperty(context.view, name);
406 | }
407 |
408 | if (lookupHit)
409 | break;
410 |
411 | context = context.parent;
412 | }
413 |
414 | cache[name] = value;
415 | }
416 |
417 | if (isFunction(value))
418 | value = value.call(this.view);
419 |
420 | return value;
421 | };
422 |
423 | /**
424 | * A Writer knows how to take a stream of tokens and render them to a
425 | * string, given a context. It also maintains a cache of templates to
426 | * avoid the need to parse the same template twice.
427 | */
428 | function Writer () {
429 | this.cache = {};
430 | }
431 |
432 | /**
433 | * Clears all cached templates in this writer.
434 | */
435 | Writer.prototype.clearCache = function clearCache () {
436 | this.cache = {};
437 | };
438 |
439 | /**
440 | * Parses and caches the given `template` and returns the array of tokens
441 | * that is generated from the parse.
442 | */
443 | Writer.prototype.parse = function parse (template, tags) {
444 | var cache = this.cache;
445 | var tokens = cache[template];
446 |
447 | if (tokens == null)
448 | tokens = cache[template] = parseTemplate(template, tags);
449 |
450 | return tokens;
451 | };
452 |
453 | /**
454 | * High-level method that is used to render the given `template` with
455 | * the given `view`.
456 | *
457 | * The optional `partials` argument may be an object that contains the
458 | * names and templates of partials that are used in the template. It may
459 | * also be a function that is used to load partial templates on the fly
460 | * that takes a single argument: the name of the partial.
461 | */
462 | Writer.prototype.render = function render (template, view, partials) {
463 | var tokens = this.parse(template);
464 | var context = (view instanceof Context) ? view : new Context(view);
465 | return this.renderTokens(tokens, context, partials, template);
466 | };
467 |
468 | /**
469 | * Low-level method that renders the given array of `tokens` using
470 | * the given `context` and `partials`.
471 | *
472 | * Note: The `originalTemplate` is only ever used to extract the portion
473 | * of the original template that was contained in a higher-order section.
474 | * If the template doesn't use higher-order sections, this argument may
475 | * be omitted.
476 | */
477 | Writer.prototype.renderTokens = function renderTokens (tokens, context, partials, originalTemplate) {
478 | var buffer = '';
479 |
480 | var token, symbol, value;
481 | for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
482 | value = undefined;
483 | token = tokens[i];
484 | symbol = token[0];
485 |
486 | if (symbol === '#') value = this.renderSection(token, context, partials, originalTemplate);
487 | else if (symbol === '^') value = this.renderInverted(token, context, partials, originalTemplate);
488 | else if (symbol === '>') value = this.renderPartial(token, context, partials, originalTemplate);
489 | else if (symbol === '&') value = this.unescapedValue(token, context);
490 | else if (symbol === 'name') value = this.escapedValue(token, context);
491 | else if (symbol === 'text') value = this.rawValue(token);
492 |
493 | if (value !== undefined)
494 | buffer += value;
495 | }
496 |
497 | return buffer;
498 | };
499 |
500 | Writer.prototype.renderSection = function renderSection (token, context, partials, originalTemplate) {
501 | var self = this;
502 | var buffer = '';
503 | var value = context.lookup(token[1]);
504 |
505 | // This function is used to render an arbitrary template
506 | // in the current context by higher-order sections.
507 | function subRender (template) {
508 | return self.render(template, context, partials);
509 | }
510 |
511 | if (!value) return;
512 |
513 | if (isArray(value)) {
514 | for (var j = 0, valueLength = value.length; j < valueLength; ++j) {
515 | buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate);
516 | }
517 | } else if (typeof value === 'object' || typeof value === 'string' || typeof value === 'number') {
518 | buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate);
519 | } else if (isFunction(value)) {
520 | if (typeof originalTemplate !== 'string')
521 | throw new Error('Cannot use higher-order sections without the original template');
522 |
523 | // Extract the portion of the original template that the section contains.
524 | value = value.call(context.view, originalTemplate.slice(token[3], token[5]), subRender);
525 |
526 | if (value != null)
527 | buffer += value;
528 | } else {
529 | buffer += this.renderTokens(token[4], context, partials, originalTemplate);
530 | }
531 | return buffer;
532 | };
533 |
534 | Writer.prototype.renderInverted = function renderInverted (token, context, partials, originalTemplate) {
535 | var value = context.lookup(token[1]);
536 |
537 | // Use JavaScript's definition of falsy. Include empty arrays.
538 | // See https://github.com/janl/mustache.js/issues/186
539 | if (!value || (isArray(value) && value.length === 0))
540 | return this.renderTokens(token[4], context, partials, originalTemplate);
541 | };
542 |
543 | Writer.prototype.renderPartial = function renderPartial (token, context, partials) {
544 | if (!partials) return;
545 |
546 | var value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
547 | if (value != null)
548 | return this.renderTokens(this.parse(value), context, partials, value);
549 | };
550 |
551 | Writer.prototype.unescapedValue = function unescapedValue (token, context) {
552 | var value = context.lookup(token[1]);
553 | if (value != null)
554 | return value;
555 | };
556 |
557 | Writer.prototype.escapedValue = function escapedValue (token, context) {
558 | var value = context.lookup(token[1]);
559 | if (value != null)
560 | return mustache.escape(value);
561 | };
562 |
563 | Writer.prototype.rawValue = function rawValue (token) {
564 | return token[1];
565 | };
566 |
567 | mustache.name = 'mustache.js';
568 | mustache.version = '2.1.3';
569 | mustache.tags = [ '{{', '}}' ];
570 |
571 | // All high-level mustache.* functions use this writer.
572 | var defaultWriter = new Writer();
573 |
574 | /**
575 | * Clears all cached templates in the default writer.
576 | */
577 | mustache.clearCache = function clearCache () {
578 | return defaultWriter.clearCache();
579 | };
580 |
581 | /**
582 | * Parses and caches the given template in the default writer and returns the
583 | * array of tokens it contains. Doing this ahead of time avoids the need to
584 | * parse templates on the fly as they are rendered.
585 | */
586 | mustache.parse = function parse (template, tags) {
587 | return defaultWriter.parse(template, tags);
588 | };
589 |
590 | /**
591 | * Renders the `template` with the given `view` and `partials` using the
592 | * default writer.
593 | */
594 | mustache.render = function render (template, view, partials) {
595 | if (typeof template !== 'string') {
596 | throw new TypeError('Invalid template! Template should be a "string" ' +
597 | 'but "' + typeStr(template) + '" was given as the first ' +
598 | 'argument for mustache#render(template, view, partials)');
599 | }
600 |
601 | return defaultWriter.render(template, view, partials);
602 | };
603 |
604 | // This is here for backwards compatibility with 0.4.x.,
605 | /*eslint-disable */ // eslint wants camel cased function name
606 | mustache.to_html = function to_html (template, view, partials, send) {
607 | /*eslint-enable*/
608 |
609 | var result = mustache.render(template, view, partials);
610 |
611 | if (isFunction(send)) {
612 | send(result);
613 | } else {
614 | return result;
615 | }
616 | };
617 |
618 | // Export the escaping function so that the user may override it.
619 | // See https://github.com/janl/mustache.js/issues/244
620 | mustache.escape = escapeHtml;
621 |
622 | // Export these mainly for testing, but also for advanced usage.
623 | mustache.Scanner = Scanner;
624 | mustache.Context = Context;
625 | mustache.Writer = Writer;
626 |
627 | }));
628 |
--------------------------------------------------------------------------------
/extensions/edge/backgroundScriptsAPIBridge.js:
--------------------------------------------------------------------------------
1 | if (!Range.prototype["intersectsNode"]) {
2 | Range.prototype["intersectsNode"] = function (node) {
3 | let range = document.createRange();
4 | range.selectNode(node);
5 | return 0 > this.compareBoundaryPoints(Range.END_TO_START, range)
6 | && 0 < this.compareBoundaryPoints(Range.START_TO_END, range);
7 | };
8 | }
9 | var getExtensionProtocol = function () {
10 | if (typeof browser == "undefined") {
11 | if (typeof chrome !== "undefined")
12 | return "chrome-extension://";
13 | }
14 | else {
15 | return "ms-browser-extension://";
16 | }
17 | };
18 | class FakeEvent {
19 | addListener(callback) { }
20 | addRules(rules, callback) { }
21 | getRules(ruleIdentifiers, callback) { }
22 | hasListener(callback) { return false; }
23 | hasListeners() { return false; }
24 | removeRules(ruleIdentifiers, callback) { }
25 | removeListener(callback) { }
26 | }
27 | class EdgeBridgeHelper {
28 | constructor() {
29 | this.fakeEvent = new FakeEvent();
30 | }
31 | toAbsolutePath(relativePath) {
32 | if (relativePath.indexOf("ms-browser-extension://") == 0) {
33 | return relativePath.replace(myBrowser.runtime.getURL(""), "");
34 | }
35 | else if (relativePath.indexOf("/") != 0) {
36 | var absolutePath = "";
37 | var documentPath = document.location.pathname;
38 | absolutePath = documentPath.substring(0, documentPath.lastIndexOf("/") + 1);
39 | absolutePath += relativePath;
40 | return absolutePath;
41 | }
42 | return relativePath;
43 | }
44 | }
45 | var bridgeHelper = new EdgeBridgeHelper();
46 | class EdgeBridgeDebugLog {
47 | constructor() {
48 | this.CatchOnException = true;
49 | this.VerboseLogging = true;
50 | this.FailedCalls = {};
51 | this.SuccededCalls = {};
52 | this.DeprecatedCalls = {};
53 | this.BridgedCalls = {};
54 | this.UnavailableApis = {};
55 | this.EdgeIssues = {};
56 | }
57 | log(message) {
58 | try {
59 | if (this.VerboseLogging) {
60 | console.log(message);
61 | }
62 | }
63 | catch (e) {
64 | }
65 | }
66 | info(message) {
67 | try {
68 | if (this.VerboseLogging) {
69 | console.info(message);
70 | }
71 | }
72 | catch (e) {
73 | }
74 | }
75 | warn(message) {
76 | try {
77 | if (this.VerboseLogging) {
78 | console.warn(message);
79 | }
80 | }
81 | catch (e) {
82 | }
83 | }
84 | error(message) {
85 | try {
86 | if (this.VerboseLogging) {
87 | console.error(message);
88 | }
89 | }
90 | catch (e) {
91 | }
92 | }
93 | DoActionAndLog(action, name, deprecatedTo, bridgedTo) {
94 | var result;
95 | try {
96 | result = action();
97 | this.AddToCalledDictionary(this.SuccededCalls, name);
98 | if (typeof deprecatedTo !== "undefined" && typeof deprecatedTo !== "null") {
99 | this.warn("API Call Deprecated - Name: " + name + ", Please use " + deprecatedTo + " instead!");
100 | this.AddToCalledDictionary(this.DeprecatedCalls, name);
101 | }
102 | if (typeof bridgedTo !== "undefined" && typeof bridgedTo !== "null") {
103 | this.info("API Call '" + name + "' has been bridged to another Edge API: " + bridgedTo);
104 | this.AddToCalledDictionary(this.BridgedCalls, name);
105 | }
106 | return result;
107 | }
108 | catch (ex) {
109 | this.AddToCalledDictionary(this.FailedCalls, name);
110 | if (this.CatchOnException)
111 | this.error("API Call Failed: " + name + " - " + ex);
112 | else
113 | throw ex;
114 | }
115 | }
116 | LogEdgeIssue(name, message) {
117 | this.warn(message);
118 | this.AddToCalledDictionary(this.EdgeIssues, name);
119 | }
120 | LogUnavailbleApi(name, deprecatedTo) {
121 | this.warn("API Call '" + name + "' is not supported in Edge");
122 | this.AddToCalledDictionary(this.UnavailableApis, name);
123 | if (typeof deprecatedTo !== "undefined" && typeof deprecatedTo !== "null") {
124 | this.warn("API Call Deprecated - Name: " + name + ", Please use " + deprecatedTo + " instead!");
125 | this.AddToCalledDictionary(this.DeprecatedCalls, name);
126 | }
127 | }
128 | AddToCalledDictionary(dictionary, name) {
129 | if (typeof dictionary[name] !== "undefined") {
130 | dictionary[name]++;
131 | }
132 | else {
133 | dictionary[name] = 1;
134 | }
135 | }
136 | }
137 | var bridgeLog = new EdgeBridgeDebugLog();
138 | class EdgeChromeAppBridge {
139 | getDetails() {
140 | return bridgeLog.DoActionAndLog(() => {
141 | return EdgeChromeRuntimeBridge.prototype.getManifest();
142 | }, "app.getManifest", undefined, "runtime.getManifest");
143 | }
144 | get isInstalled() { return bridgeLog.DoActionAndLog(() => { throw "app.isInstalled is not available in Edge"; }, "app.isInstalled"); }
145 | getIsInstalled() { return bridgeLog.DoActionAndLog(() => { throw "app.getIsInstalled is not available in the Edge"; }, "app.getIsInstalled"); }
146 | installState() { return bridgeLog.DoActionAndLog(() => { throw "app.installState is not available in Edge"; }, "app.installState"); }
147 | runningState() { return bridgeLog.DoActionAndLog(() => { throw "app.runningState is not available in Edge"; }, "app.runningState"); }
148 | }
149 | class EdgeBrowserActionBridge {
150 | get onClicked() { return bridgeLog.DoActionAndLog(() => { return myBrowser.browserAction.onClicked; }, "browserAction.onClicked"); }
151 | disable(tabId) {
152 | bridgeLog.DoActionAndLog(() => {
153 | myBrowser.browserAction.disable(tabId);
154 | }, "browserAction.disable");
155 | }
156 | enable(tabId) {
157 | bridgeLog.DoActionAndLog(() => {
158 | if (typeof tabId !== "undefined" && typeof tabId !== "null") {
159 | myBrowser.browserAction.enable(tabId);
160 | }
161 | else {
162 | myBrowser.browserAction.enable();
163 | }
164 | }, "browserAction.Enable");
165 | }
166 | getBadgeBackgroundColor(details, callback) {
167 | bridgeLog.DoActionAndLog(() => {
168 | myBrowser.browserAction.getBadgeBackgroundColor(details, callback);
169 | }, "browserAction.getBadgeBackgroundColor");
170 | }
171 | getBadgeText(details, callback) {
172 | bridgeLog.DoActionAndLog(() => {
173 | myBrowser.browserAction.getBadgeText(details, callback);
174 | }, "browserAction.getBadgeText");
175 | }
176 | setBadgeBackgroundColor(details) {
177 | bridgeLog.DoActionAndLog(() => {
178 | myBrowser.browserAction.setBadgeBackgroundColor(details);
179 | }, "browserAction.setBadgeBackgroundColor");
180 | }
181 | setBadgeText(details) {
182 | bridgeLog.DoActionAndLog(() => {
183 | myBrowser.browserAction.setBadgeText(details);
184 | }, "browserAction.setBadgeText");
185 | }
186 | setIcon(details, callback) {
187 | bridgeLog.DoActionAndLog(() => {
188 | if (typeof details.path !== "undefined") {
189 | if (typeof details.path === "object") {
190 | for (var key in details.path) {
191 | if (details.path.hasOwnProperty(key)) {
192 | details.path[key] = bridgeHelper.toAbsolutePath(details.path[key]);
193 | }
194 | }
195 | }
196 | else {
197 | details.path = bridgeHelper.toAbsolutePath(details.path);
198 | }
199 | }
200 | if (typeof callback !== "undefined" && typeof callback !== "null") {
201 | myBrowser.browserAction.setIcon(details, callback);
202 | }
203 | else {
204 | myBrowser.browserAction.setIcon(details);
205 | }
206 | }, "browserAction.setIcon", undefined, "browserAction.setIcon with absolute path");
207 | }
208 | setPopup(details) {
209 | bridgeLog.DoActionAndLog(() => {
210 | myBrowser.browserAction.setPopup(details);
211 | }, "browserAction.setPopup");
212 | }
213 | }
214 | class EdgeChromeBrowserActionBridge extends EdgeBrowserActionBridge {
215 | getPopup(details, callback) {
216 | bridgeLog.LogUnavailbleApi("browserAction.getPopup");
217 | }
218 | getTitle(details, callback) {
219 | bridgeLog.LogUnavailbleApi("browserAction.getTitle");
220 | }
221 | setTitle(details) {
222 | bridgeLog.LogUnavailbleApi("browserAction.setTitle");
223 | }
224 | }
225 | class EdgeContextMenusBridge {
226 | get ACTION_MENU_TOP_LEVEL_LIMIT() { return bridgeLog.DoActionAndLog(() => { return myBrowser.contextMenus.ACTION_MENU_TOP_LEVEL_LIMIT; }, "contextMenus.ACTION_MENU_TOP_LEVEL_LIMIT"); }
227 | get onClicked() { return bridgeLog.DoActionAndLog(() => { return myBrowser.contextMenus.onClicked; }, "contextMenus.onClicked"); }
228 | create(createProperties, callback) {
229 | bridgeLog.DoActionAndLog(() => {
230 | if (typeof callback !== "undefined" && typeof callback !== "null") {
231 | myBrowser.contextMenus.create(createProperties, callback);
232 | }
233 | else {
234 | myBrowser.contextMenus.create(createProperties);
235 | }
236 | }, "contextMenus.create");
237 | }
238 | remove(menuItemId, callback) {
239 | bridgeLog.DoActionAndLog(() => {
240 | if (typeof callback !== "undefined" && typeof callback !== "null") {
241 | myBrowser.contextMenus.remove(menuItemId, callback);
242 | }
243 | else {
244 | myBrowser.contextMenus.remove(menuItemId);
245 | }
246 | }, "contextMenus.remove");
247 | }
248 | removeAll(callback) {
249 | bridgeLog.DoActionAndLog(() => {
250 | if (typeof callback !== "undefined" && typeof callback !== "null") {
251 | myBrowser.contextMenus.removeAll(callback);
252 | }
253 | else {
254 | myBrowser.contextMenus.removeAll();
255 | }
256 | }, "contextMenus.removeAll");
257 | }
258 | update(id, updateProperties, callback) {
259 | bridgeLog.DoActionAndLog(() => {
260 | if (typeof callback !== "undefined" && typeof callback !== "null") {
261 | myBrowser.contextMenus.update(id, updateProperties, callback);
262 | }
263 | else {
264 | myBrowser.contextMenus.update(id, updateProperties);
265 | }
266 | }, "contextMenus.update");
267 | }
268 | }
269 | class EdgeCookiesBridge {
270 | get(details, callback) {
271 | bridgeLog.DoActionAndLog(() => {
272 | myBrowser.cookies.get(details, callback);
273 | }, "cookies.get");
274 | }
275 | getAll(details, callback) {
276 | bridgeLog.DoActionAndLog(() => {
277 | myBrowser.cookies.getAll(details, callback);
278 | }, "cookies.getAll");
279 | }
280 | remove(details, callback) {
281 | bridgeLog.DoActionAndLog(() => {
282 | if (typeof callback !== "undefined" && typeof callback !== "null") {
283 | myBrowser.cookies.remove(details, callback);
284 | }
285 | else {
286 | myBrowser.cookies.remove(details);
287 | }
288 | }, "cookies.remove");
289 | }
290 | set(details, callback) {
291 | bridgeLog.DoActionAndLog(() => {
292 | if (typeof callback !== "undefined" && typeof callback !== "null") {
293 | myBrowser.cookies.set(details, callback);
294 | }
295 | else {
296 | myBrowser.cookies.set(details);
297 | }
298 | }, "cookies.set");
299 | }
300 | }
301 | class EdgeChromeCookiesBridge extends EdgeCookiesBridge {
302 | get onChanged() { bridgeLog.LogUnavailbleApi("cookies.onChanged"); return bridgeHelper.fakeEvent; }
303 | }
304 | class EdgeExtensionBridge {
305 | getBackgroundPage() {
306 | return bridgeLog.DoActionAndLog(() => {
307 | return myBrowser.extension.getBackgroundPage();
308 | }, "extension.getBackgroundPage");
309 | }
310 | getURL(path) {
311 | return bridgeLog.DoActionAndLog(() => {
312 | return myBrowser.extension.getURL(path);
313 | }, "extension.getURL");
314 | }
315 | getViews(fetchProperties) {
316 | return bridgeLog.DoActionAndLog(() => {
317 | return myBrowser.extension.getViews(fetchProperties);
318 | }, "extension.getViews");
319 | }
320 | }
321 | class EdgeChromeExtensionBridge extends EdgeExtensionBridge {
322 | get onConnect() { return bridgeLog.DoActionAndLog(() => { return EdgeRuntimeBridge.prototype.onConnect; }, "extension.onConnect", "runtime.onConnect", "runtime.onConnect"); }
323 | get onMessage() { return bridgeLog.DoActionAndLog(() => { return myBrowser.runtime.onMessage; }, "extension.onMessage", "runtime.onMessage", "runtime.onMessage"); }
324 | get onRequest() { return bridgeLog.DoActionAndLog(() => { return myBrowser.runtime.onMessage; }, "extension.onRequest", "runtime.onMessage", "runtime.onMessage"); }
325 | get onRequestExternal() { return bridgeLog.DoActionAndLog(() => { return myBrowser.runtime.onMessageExternal; }, "extension.onRequestExternal", "runtime.onMessageExternal", "runtime.onMessageExternal"); }
326 | get inIncognitoContext() { return bridgeLog.DoActionAndLog(() => { return myBrowser.extension["inPrivateContext"]; }, "extension.inIncognitoContext", undefined, "extension.inPrivateContext"); }
327 | get lastError() { return bridgeLog.DoActionAndLog(() => { return myBrowser.runtime.lastError; }, "extension.lastError", undefined, "runtime.lastError"); }
328 | connect(extensionId, connectInfo) {
329 | return bridgeLog.DoActionAndLog(() => {
330 | return EdgeRuntimeBridge.prototype.connect(extensionId, connectInfo);
331 | }, "extension.connect", "runtime.connect", "runtime.connect");
332 | }
333 | sendMessage(message, responseCallback) {
334 | return bridgeLog.DoActionAndLog(() => {
335 | return EdgeRuntimeBridge.prototype.sendMessage(message, responseCallback, undefined, undefined);
336 | }, "extension.sendMessage", "runtime.sendMessage", "runtime.sendMessage");
337 | }
338 | sendRequest(extensionId, message, options, responseCallback) {
339 | return bridgeLog.DoActionAndLog(() => {
340 | return EdgeRuntimeBridge.prototype.sendMessage(extensionId, message, options, responseCallback);
341 | }, "extension.sendRequest", "runtime.sendMessage", "runtime.sendMessage");
342 | }
343 | isAllowedFileSchemeAccess(callback) {
344 | bridgeLog.LogUnavailbleApi("extension.isAllowedFileSchemeAccess");
345 | }
346 | isAllowedIncognitoAccess(callback) {
347 | bridgeLog.LogUnavailbleApi("extension.isAllowedIncognitoAccess");
348 | }
349 | setUpdateUrlData(data) {
350 | bridgeLog.LogUnavailbleApi("extension.setUpdateUrlData");
351 | }
352 | }
353 | class EdgeHistoryBridge {
354 | get onVisited() { bridgeLog.LogUnavailbleApi("history.onVisited"); return bridgeHelper.fakeEvent; }
355 | get onVisitRemoved() { bridgeLog.LogUnavailbleApi("history.onVisitRemoved"); return bridgeHelper.fakeEvent; }
356 | addUrl(details, callback) {
357 | bridgeLog.LogUnavailbleApi("history.addUrl");
358 | }
359 | deleteAll(callback) {
360 | bridgeLog.LogUnavailbleApi("history.deleteAll");
361 | }
362 | deleteRange(range, callback) {
363 | bridgeLog.LogUnavailbleApi("history.deleteRange");
364 | }
365 | deleteUrl(details, callback) {
366 | bridgeLog.LogUnavailbleApi("history.deleteUrl");
367 | }
368 | getVisits(details, callback) {
369 | bridgeLog.LogUnavailbleApi("history.getVisits");
370 | }
371 | search(query, callback) {
372 | bridgeLog.LogUnavailbleApi("history.search");
373 | }
374 | }
375 | class EdgeI18nBridge {
376 | getAcceptLanguages(callback) {
377 | return bridgeLog.DoActionAndLog(() => {
378 | return myBrowser.i18n.getAcceptLanguages(callback);
379 | }, "i18n.getAcceptLanguages");
380 | }
381 | getMessage(messageName, substitutions) {
382 | return bridgeLog.DoActionAndLog(() => {
383 | if (messageName.indexOf("@@extension_id") > -1) {
384 | return myBrowser.runtime.id;
385 | }
386 | if (typeof substitutions !== "undefined" && typeof substitutions !== "null") {
387 | return myBrowser.i18n.getMessage(messageName, substitutions);
388 | }
389 | else {
390 | return myBrowser.i18n.getMessage(messageName);
391 | }
392 | }, "i18n.getMessage");
393 | }
394 | getUILanguage() {
395 | return bridgeLog.DoActionAndLog(() => {
396 | return myBrowser.i18n.getUILanguage();
397 | }, "i18n.getUILanguage");
398 | }
399 | }
400 | class EdgeNotificationBridge {
401 | get onButtonClicked() { bridgeLog.LogUnavailbleApi("notifications.onButtonClicked"); return bridgeHelper.fakeEvent; }
402 | get onClicked() { bridgeLog.LogUnavailbleApi("notifications.onClicked"); return bridgeHelper.fakeEvent; }
403 | get onClosed() { bridgeLog.LogUnavailbleApi("notifications.onClosed"); return bridgeHelper.fakeEvent; }
404 | get onPermissionLevelChanged() { bridgeLog.LogUnavailbleApi("notifications.onPermissionLevelChanged"); return bridgeHelper.fakeEvent; }
405 | get onShowSettings() { bridgeLog.LogUnavailbleApi("notifications.onShowSettings"); return bridgeHelper.fakeEvent; }
406 | clear(notificationId, callback) {
407 | bridgeLog.LogUnavailbleApi("notifications.clear");
408 | }
409 | create(notificationId, options, callback) {
410 | bridgeLog.LogUnavailbleApi("notifications.create");
411 | }
412 | getAll(callback) {
413 | bridgeLog.LogUnavailbleApi("notifications.getAll");
414 | }
415 | getPermissionLevel(callback) {
416 | bridgeLog.LogUnavailbleApi("notifications.getPermissionLevel");
417 | }
418 | update(notificationId, options, callback) {
419 | bridgeLog.LogUnavailbleApi("notifications.update");
420 | }
421 | }
422 | class EdgePageActionBridge {
423 | get onClicked() { return bridgeLog.DoActionAndLog(() => { return myBrowser.pageAction.onClicked; }, "pageAction.onClicked"); }
424 | getPopup(details, callback) {
425 | bridgeLog.DoActionAndLog(() => {
426 | myBrowser.pageAction.getPopup(details, callback);
427 | }, "pageAction.getPopup");
428 | }
429 | getTitle(details, callback) {
430 | bridgeLog.DoActionAndLog(() => {
431 | myBrowser.pageAction.getTitle(details, callback);
432 | }, "pageAction.getTitle");
433 | }
434 | hide(tabId) {
435 | bridgeLog.DoActionAndLog(() => {
436 | myBrowser.pageAction.hide(tabId);
437 | }, "pageAction.hide");
438 | }
439 | setTitle(details) {
440 | bridgeLog.DoActionAndLog(() => {
441 | myBrowser.pageAction.setTitle(details);
442 | }, "pageAction.setTitle");
443 | }
444 | setIcon(details, callback) {
445 | bridgeLog.DoActionAndLog(() => {
446 | if (typeof callback !== "undefined" && typeof callback !== "null") {
447 | myBrowser.pageAction.setIcon(details, callback);
448 | }
449 | else {
450 | myBrowser.pageAction.setIcon(details, callback);
451 | }
452 | }, "pageAction.setIcon");
453 | }
454 | setPopup(details) {
455 | bridgeLog.DoActionAndLog(() => {
456 | myBrowser.pageAction.setPopup(details);
457 | }, "pageAction.setPopup");
458 | }
459 | show(tabId) {
460 | bridgeLog.DoActionAndLog(() => {
461 | myBrowser.pageAction.show(tabId);
462 | }, "pageAction.show");
463 | }
464 | }
465 | class EdgePermissionsBridge {
466 | get onAdded() { bridgeLog.LogUnavailbleApi("permissions.onAdded"); return bridgeHelper.fakeEvent; }
467 | get onRemoved() { bridgeLog.LogUnavailbleApi("permissions.onRemoved"); return bridgeHelper.fakeEvent; }
468 | contains(permissions, callback) {
469 | bridgeLog.LogUnavailbleApi("permissions.contains");
470 | }
471 | getAll(callback) {
472 | bridgeLog.LogUnavailbleApi("permissions.getAll");
473 | }
474 | remove(permissions, callback) {
475 | bridgeLog.LogUnavailbleApi("permissions.remove");
476 | }
477 | request(permissions, callback) {
478 | bridgeLog.LogUnavailbleApi("permissions.request");
479 | }
480 | }
481 | class EdgeRuntimeBridge {
482 | get id() { return bridgeLog.DoActionAndLog(() => { return myBrowser.runtime.id; }, "runtime.id"); }
483 | get lastError() { return bridgeLog.DoActionAndLog(() => { return myBrowser.runtime.lastError; }, "runtime.lastError"); }
484 | get onConnect() { return bridgeLog.DoActionAndLog(() => { return myBrowser.runtime.onConnect; }, "runtime.onConnect"); }
485 | get onInstalled() { return bridgeLog.DoActionAndLog(() => { return myBrowser.runtime.onInstalled; }, "runtime.onInstalled"); }
486 | get onMessage() { return bridgeLog.DoActionAndLog(() => { return myBrowser.runtime.onMessage; }, "runtime.onMessage"); }
487 | get onMessageExternal() { return bridgeLog.DoActionAndLog(() => { return myBrowser.runtime.onMessageExternal; }, "runtime.onMessageExternal"); }
488 | connect(extensionId, connectInfo) {
489 | return bridgeLog.DoActionAndLog(() => {
490 | if (typeof connectInfo !== "undefined" && typeof connectInfo !== "null") {
491 | return myBrowser.runtime.connect(extensionId, connectInfo);
492 | }
493 | else {
494 | return myBrowser.runtime.connect(extensionId);
495 | }
496 | }, "runtime.connect");
497 | }
498 | getBackgroundPage(callback) {
499 | bridgeLog.DoActionAndLog(() => {
500 | myBrowser.runtime.getBackgroundPage(callback);
501 | }, "runtime.getBackgroundPage");
502 | }
503 | getManifest() {
504 | return bridgeLog.DoActionAndLog(() => {
505 | return myBrowser.runtime.getManifest();
506 | }, "runtime.getManifest");
507 | }
508 | getURL(path) {
509 | return bridgeLog.DoActionAndLog(() => {
510 | return myBrowser.runtime.getURL(path);
511 | }, "runtime.getURL");
512 | }
513 | sendMessage(extensionId, message, options, responseCallback) {
514 | bridgeLog.DoActionAndLog(() => {
515 | if (typeof responseCallback !== "undefined" && typeof responseCallback !== "null") {
516 | myBrowser.runtime.sendMessage(extensionId, message, options, responseCallback);
517 | }
518 | else if (typeof options !== "undefined" && typeof options !== "null") {
519 | myBrowser.runtime.sendMessage(extensionId, message, options);
520 | }
521 | else if (typeof message !== "undefined" && typeof message !== "null") {
522 | myBrowser.runtime.sendMessage(extensionId, message);
523 | }
524 | else {
525 | myBrowser.runtime.sendMessage(undefined, extensionId);
526 | }
527 | }, "runtime.sendMessage");
528 | }
529 | }
530 | class EdgeChromeRuntimeBridge extends EdgeRuntimeBridge {
531 | get onConnectExternal() { bridgeLog.LogUnavailbleApi("runtime.onConnectExternal"); return bridgeHelper.fakeEvent; }
532 | get onRestartRequired() { bridgeLog.LogUnavailbleApi("runtime.onRestartRequired"); return bridgeHelper.fakeEvent; }
533 | get onStartup() { bridgeLog.LogUnavailbleApi("runtime.onStartup"); return bridgeHelper.fakeEvent; }
534 | get onSuspend() { bridgeLog.LogUnavailbleApi("runtime.onSuspend"); return bridgeHelper.fakeEvent; }
535 | get onSuspendCanceled() { bridgeLog.LogUnavailbleApi("runtime.onSuspendCanceled"); return bridgeHelper.fakeEvent; }
536 | get onUpdateAvailable() { bridgeLog.LogUnavailbleApi("runtime.onUpdateAvailable"); return bridgeHelper.fakeEvent; }
537 | openOptionsPage(callback) {
538 | bridgeLog.DoActionAndLog(() => {
539 | var optionsPage = myBrowser.runtime.getManifest()["options_page"];
540 | var optionsPageUrl = myBrowser.runtime.getURL(optionsPage);
541 | if (typeof callback !== "undefined" && typeof callback !== "null") {
542 | myBrowser.tabs.create({ url: optionsPageUrl }, callback);
543 | }
544 | else {
545 | myBrowser.tabs.create({ url: optionsPageUrl });
546 | }
547 | }, "runtime.openOptionsPage", undefined, "tabs.create({ url: optionsPageUrl })");
548 | }
549 | connectNative(application) {
550 | bridgeLog.LogUnavailbleApi("runtime.connectNative");
551 | return null;
552 | }
553 | getPackageDirectoryEntry(callback) {
554 | bridgeLog.LogUnavailbleApi("runtime.getPackageDirectoryEntry");
555 | }
556 | getPlatformInfo(callback) {
557 | bridgeLog.LogUnavailbleApi("runtime.getPlatformInfo");
558 | }
559 | reload() {
560 | bridgeLog.LogUnavailbleApi("runtime.reload");
561 | }
562 | requestUpdateCheck(callback) {
563 | bridgeLog.LogUnavailbleApi("runtime.requestUpdateCheck");
564 | }
565 | restart() {
566 | bridgeLog.LogUnavailbleApi("runtime.restart");
567 | }
568 | setUninstallURL(url, callback) {
569 | bridgeLog.LogUnavailbleApi("runtime.setUninstallURL");
570 | }
571 | sendNativeMessage(application, message, responseCallback) {
572 | bridgeLog.LogUnavailbleApi("runtime.sendNativeMessage");
573 | }
574 | }
575 | class EdgeStorageBridge {
576 | get local() { return bridgeLog.DoActionAndLog(() => { return myBrowser.storage.local; }, "storage.local"); }
577 | get onChanged() { return bridgeLog.DoActionAndLog(() => { return myBrowser.storage.onChanged; }, "storage.onChanged"); }
578 | }
579 | class EdgeChromeStorageBridge extends EdgeStorageBridge {
580 | get managed() { return bridgeLog.DoActionAndLog(() => { return myBrowser.storage.local; }, "storage.managed", undefined, "storage.local"); }
581 | get sync() { return bridgeLog.DoActionAndLog(() => { return myBrowser.storage.local; }, "storage.sync", undefined, "storage.local"); }
582 | }
583 | class EdgeTabsBridge {
584 | get onActivated() { return bridgeLog.DoActionAndLog(() => { return myBrowser.tabs.onActivated; }, "tabs.onActivated"); }
585 | get onCreated() { return bridgeLog.DoActionAndLog(() => { return myBrowser.tabs.onCreated; }, "tabs.onCreated"); }
586 | get onRemoved() { return bridgeLog.DoActionAndLog(() => { return myBrowser.tabs.onRemoved; }, "tabs.onRemoved"); }
587 | get onReplaced() { return bridgeLog.DoActionAndLog(() => { return myBrowser.tabs.onReplaced; }, "tabs.onReplaced"); }
588 | get onUpdated() { return bridgeLog.DoActionAndLog(() => { return myBrowser.tabs.onUpdated; }, "tabs.onUpdated"); }
589 | create(createProperties, callback) {
590 | bridgeLog.DoActionAndLog(() => {
591 | if (typeof callback !== "undefined" && typeof callback !== "null") {
592 | myBrowser.tabs.create(createProperties, callback);
593 | }
594 | else {
595 | myBrowser.tabs.create(createProperties);
596 | }
597 | }, "tabs.create");
598 | }
599 | detectLanguage(tabId, callback) {
600 | bridgeLog.DoActionAndLog(() => {
601 | myBrowser.tabs.detectLanguage(tabId, callback);
602 | }, "tabs.detectLanguage");
603 | }
604 | executeScript(tabId, details, callback) {
605 | bridgeLog.DoActionAndLog(() => {
606 | if (typeof callback !== "undefined" && typeof callback !== "null") {
607 | myBrowser.tabs.executeScript(tabId, details, callback);
608 | }
609 | else {
610 | myBrowser.tabs.executeScript(tabId, details);
611 | }
612 | }, "tabs.executeScript");
613 | }
614 | get(tabId, callback) {
615 | bridgeLog.DoActionAndLog(() => {
616 | myBrowser.tabs.get(tabId, callback);
617 | }, "tabs.get");
618 | }
619 | getCurrent(callback) {
620 | bridgeLog.DoActionAndLog(() => {
621 | myBrowser.tabs.getCurrent(callback);
622 | }, "tabs.getCurrent");
623 | }
624 | insertCSS(tabId, details, callback) {
625 | bridgeLog.DoActionAndLog(() => {
626 | if (typeof callback !== "undefined" && typeof callback !== "null") {
627 | myBrowser.tabs.insertCSS(tabId, details, callback);
628 | }
629 | else {
630 | myBrowser.tabs.insertCSS(tabId, details);
631 | }
632 | }, "tabs.insertCSS");
633 | }
634 | query(queryInfo, callback) {
635 | bridgeLog.DoActionAndLog(() => {
636 | myBrowser.tabs.query(queryInfo, callback);
637 | }, "tabs.query");
638 | }
639 | remove(tabId, callback) {
640 | bridgeLog.DoActionAndLog(() => {
641 | if (typeof callback !== "undefined" && typeof callback !== "null") {
642 | myBrowser.tabs.remove(tabId, callback);
643 | }
644 | else {
645 | myBrowser.tabs.remove(tabId);
646 | }
647 | }, "tabs.remove");
648 | }
649 | sendMessage(tabId, message, responseCallback) {
650 | bridgeLog.DoActionAndLog(() => {
651 | if (typeof responseCallback !== "undefined" && typeof responseCallback !== "null") {
652 | myBrowser.tabs.sendMessage(tabId, message, responseCallback);
653 | }
654 | else {
655 | myBrowser.tabs.sendMessage(tabId, message);
656 | }
657 | }, "tabs.sendMessage");
658 | }
659 | update(tabId, updateProperties, callback) {
660 | bridgeLog.DoActionAndLog(() => {
661 | if (typeof callback !== "undefined" && typeof callback !== "null") {
662 | myBrowser.tabs.update(tabId, updateProperties, callback);
663 | }
664 | else {
665 | myBrowser.tabs.update(tabId, updateProperties);
666 | }
667 | }, "tabs.update");
668 | }
669 | }
670 | class EdgeChromeTabsBridge extends EdgeTabsBridge {
671 | get onAttached() { bridgeLog.LogUnavailbleApi("tabs.onAttached"); return bridgeHelper.fakeEvent; }
672 | get onDetached() { bridgeLog.LogUnavailbleApi("tabs.onDetached"); return bridgeHelper.fakeEvent; }
673 | get onHighlighted() { bridgeLog.LogUnavailbleApi("tabs.onHighlighted"); return bridgeHelper.fakeEvent; }
674 | get onMoved() { bridgeLog.LogUnavailbleApi("tabs.onMoved"); return bridgeHelper.fakeEvent; }
675 | get onSelectionChanged() {
676 | return bridgeLog.DoActionAndLog(() => {
677 | var fakeEvent = bridgeHelper.fakeEvent;
678 | fakeEvent.addListener = (callback) => {
679 | myBrowser.tabs.onActivated.addListener((activeInfo) => {
680 | callback(activeInfo.tabId, { windowId: activeInfo.windowId });
681 | });
682 | };
683 | return fakeEvent;
684 | }, "tabs.onSelectionChanged", "tabs.onActivated", "tabs.onActivated");
685 | }
686 | duplicate(tabId, callback) {
687 | bridgeLog.DoActionAndLog(() => {
688 | this.get(tabId, function (tab) {
689 | if (typeof callback !== "undefined" && typeof callback !== "null") {
690 | myBrowser.tabs.create({ url: tab.url }, callback);
691 | }
692 | else {
693 | myBrowser.tabs.create({ url: tab.url });
694 | }
695 | });
696 | }, "tabs.duplicate", undefined, "tabs.create");
697 | }
698 | getAllInWindow(windowId, callback) {
699 | bridgeLog.DoActionAndLog(() => {
700 | this.query({ windowId: windowId }, callback);
701 | }, "tabs.getAllInWindow", "tabs.query", "tabs.query");
702 | }
703 | getSelected(windowId, callback) {
704 | bridgeLog.DoActionAndLog(() => {
705 | this.query({ active: true }, (tabs) => callback(tabs[0]));
706 | }, "tabs.getSelected", "tabs.query", "tabs.query");
707 | }
708 | sendRequest(tabId, request, responseCallback) {
709 | bridgeLog.DoActionAndLog(() => {
710 | this.sendMessage(tabId, request, responseCallback);
711 | }, "tabs.sendRequest", "tabs.sendMessage", "tabs.sendMessage");
712 | }
713 | captureVisibleTab(windowId, options, callback) {
714 | bridgeLog.LogUnavailbleApi("tabs.captureVisibleTab");
715 | }
716 | connect(tabId, connectInfo) {
717 | bridgeLog.LogUnavailbleApi("tabs.connect");
718 | return null;
719 | }
720 | highlight(highlightInfo, callback) {
721 | bridgeLog.LogUnavailbleApi("tabs.highlight");
722 | }
723 | move(tabId, moveProperties, callback) {
724 | bridgeLog.LogUnavailbleApi("tabs.move");
725 | }
726 | reload(tabId, reloadProperties, callback) {
727 | bridgeLog.LogUnavailbleApi("tabs.reload");
728 | }
729 | }
730 | class EdgeWebNavigationBridge {
731 | get onBeforeNavigate() { return bridgeLog.DoActionAndLog(() => { return myBrowser.webNavigation.onBeforeNavigate; }, "webNavigation.onBeforeNavigate"); }
732 | get onCommitted() { return bridgeLog.DoActionAndLog(() => { return myBrowser.webNavigation.onCommitted; }, "webNavigation.onCommitted"); }
733 | get onCompleted() { return bridgeLog.DoActionAndLog(() => { return myBrowser.webNavigation.onCompleted; }, "webNavigation.onCompleted"); }
734 | get onCreatedNavigationTarget() { return bridgeLog.DoActionAndLog(() => { return myBrowser.webNavigation.onCreatedNavigationTarget; }, "webNavigation.onCreatedNavigationTarget"); }
735 | get onDOMContentLoaded() { return bridgeLog.DoActionAndLog(() => { return myBrowser.webNavigation.onDOMContentLoaded; }, "webNavigation.onDOMContentLoaded"); }
736 | get onErrorOccurred() { return bridgeLog.DoActionAndLog(() => { return myBrowser.webNavigation.onErrorOccurred; }, "webNavigation.onErrorOccurred"); }
737 | get onHistoryStateUpdated() { return bridgeLog.DoActionAndLog(() => { return myBrowser.webNavigation.onHistoryStateUpdated; }, "webNavigation.onHistoryStateUpdated"); }
738 | get onReferenceFragmentUpdated() { return bridgeLog.DoActionAndLog(() => { return myBrowser.webNavigation.onReferenceFragmentUpdated; }, "webNavigation.onReferenceFragmentUpdated"); }
739 | get onTabReplaced() { return bridgeLog.DoActionAndLog(() => { return myBrowser.webNavigation.onTabReplaced; }, "webNavigation.onTabReplaced"); }
740 | getAllFrames(details, callback) {
741 | bridgeLog.DoActionAndLog(() => {
742 | myBrowser.webNavigation.getAllFrames(details, callback);
743 | }, "webNavigation.getAllFrames");
744 | }
745 | getFrame(details, callback) {
746 | bridgeLog.DoActionAndLog(() => {
747 | myBrowser.webNavigation.getFrame(details, callback);
748 | }, "webNavigation.getFrame");
749 | }
750 | }
751 | class EdgeWebRequestBridge {
752 | get MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES() { return bridgeLog.DoActionAndLog(() => { return myBrowser.webRequest.MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES; }, "webNavigation.MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES"); }
753 | get onAuthRequired() { return bridgeLog.DoActionAndLog(() => { return myBrowser.webRequest.onAuthRequired; }, "webNavigation.onAuthRequired"); }
754 | get onBeforeRedirect() { return bridgeLog.DoActionAndLog(() => { return myBrowser.webRequest.onBeforeRedirect; }, "webNavigation.onBeforeRedirect"); }
755 | get onBeforeRequest() { return bridgeLog.DoActionAndLog(() => { return myBrowser.webRequest.onBeforeRequest; }, "webNavigation.onBeforeRequest"); }
756 | get onBeforeSendHeaders() { return bridgeLog.DoActionAndLog(() => { return myBrowser.webRequest.onBeforeSendHeaders; }, "webNavigation.onBeforeSendHeaders"); }
757 | get onCompleted() { return bridgeLog.DoActionAndLog(() => { return myBrowser.webRequest.onCompleted; }, "webNavigation.onCompleted"); }
758 | get onErrorOccurred() { return bridgeLog.DoActionAndLog(() => { return myBrowser.webRequest.onErrorOccurred; }, "webNavigation.onErrorOccurred"); }
759 | get onHeadersReceived() { return bridgeLog.DoActionAndLog(() => { return myBrowser.webRequest.onHeadersReceived; }, "webNavigation.onHeadersReceived"); }
760 | get onResponseStarted() { return bridgeLog.DoActionAndLog(() => { return myBrowser.webRequest.onResponseStarted; }, "webNavigation.onResponseStarted"); }
761 | get onSendHeaders() { return bridgeLog.DoActionAndLog(() => { return myBrowser.webRequest.onSendHeaders; }, "webNavigation.onSendHeaders"); }
762 | handlerBehaviorChanged(callback) {
763 | bridgeLog.DoActionAndLog(() => {
764 | if (typeof callback !== "undefined" && typeof callback !== "null") {
765 | myBrowser.webRequest.handlerBehaviorChanged(callback);
766 | }
767 | else {
768 | myBrowser.webRequest.handlerBehaviorChanged();
769 | }
770 | }, "webRequest.handlerBehaviorChanged");
771 | }
772 | }
773 | class EdgeWindowsBridge {
774 | get WINDOW_ID_CURRENT() { return bridgeLog.DoActionAndLog(() => { return myBrowser.windows.WINDOW_ID_CURRENT; }, "windows.WINDOW_ID_CURRENT"); }
775 | get WINDOW_ID_NONE() { return bridgeLog.DoActionAndLog(() => { return myBrowser.windows.WINDOW_ID_NONE; }, "windows.WINDOW_ID_NONE"); }
776 | get onCreated() { return bridgeLog.DoActionAndLog(() => { return myBrowser.windows.onCreated; }, "windows.onCreated"); }
777 | get onFocusChanged() { return bridgeLog.DoActionAndLog(() => { return myBrowser.windows.onFocusChanged; }, "windows.onFocusChanged"); }
778 | get onRemoved() { return bridgeLog.DoActionAndLog(() => { return myBrowser.windows.onRemoved; }, "windows.onRemoved"); }
779 | create(createData, callback) {
780 | bridgeLog.DoActionAndLog(() => {
781 | if (typeof callback !== "undefined" && typeof callback !== "null") {
782 | myBrowser.windows.create(createData, callback);
783 | }
784 | else {
785 | myBrowser.windows.create(createData);
786 | }
787 | }, "windows.create");
788 | }
789 | get(windowId, getInfo, callback) {
790 | bridgeLog.DoActionAndLog(() => {
791 | myBrowser.windows.get(windowId, getInfo, callback);
792 | }, "windows.get");
793 | }
794 | getAll(getInfo, callback) {
795 | bridgeLog.DoActionAndLog(() => {
796 | myBrowser.windows.getAll(getInfo, callback);
797 | }, "windows.getAll");
798 | }
799 | getCurrent(getInfo, callback) {
800 | bridgeLog.DoActionAndLog(() => {
801 | myBrowser.windows.getCurrent(getInfo, callback);
802 | }, "windows.getCurrent");
803 | }
804 | getLastFocused(getInfo, callback) {
805 | bridgeLog.DoActionAndLog(() => {
806 | myBrowser.windows.getLastFocused(getInfo, callback);
807 | }, "windows.getLastFocused");
808 | }
809 | update(windowId, updateInfo, callback) {
810 | bridgeLog.DoActionAndLog(() => {
811 | if (typeof callback !== "undefined" && typeof callback !== "null") {
812 | myBrowser.windows.update(windowId, updateInfo, callback);
813 | }
814 | else {
815 | myBrowser.windows.update(windowId, updateInfo);
816 | }
817 | }, "windows.update");
818 | }
819 | }
820 | class EdgeChromeWindowsBridge extends EdgeWindowsBridge {
821 | remove(windowId, callback) {
822 | bridgeLog.LogUnavailbleApi("windows.remove");
823 | }
824 | }
825 | class EdgeBackgroundBridge {
826 | constructor() {
827 | this.app = new EdgeChromeAppBridge();
828 | this.browserAction = typeof browser.browserAction !== "undefined" ? new EdgeChromeBrowserActionBridge() : undefined;
829 | this.contextMenus = typeof browser.contextMenus !== "undefined" ? new EdgeContextMenusBridge() : undefined;
830 | this.cookies = typeof browser.cookies !== "undefined" ? new EdgeChromeCookiesBridge() : undefined;
831 | this.extension = typeof browser.extension !== "undefined" ? new EdgeChromeExtensionBridge() : undefined;
832 | this.history = typeof browser.history !== "undefined" ? new EdgeHistoryBridge() : undefined;
833 | this.i18n = typeof browser.i18n !== "undefined" ? new EdgeI18nBridge() : undefined;
834 | this.notifications = typeof browser.notifications !== "undefined" ? new EdgeNotificationBridge() : undefined;
835 | this.pageAction = typeof browser.pageAction !== "undefined" ? new EdgePageActionBridge() : undefined;
836 | this.permissions = typeof browser.permissions !== "undefined" ? new EdgePermissionsBridge() : undefined;
837 | this.runtime = typeof browser.runtime !== "undefined" ? new EdgeChromeRuntimeBridge() : undefined;
838 | this.storage = typeof browser.storage !== "undefined" ? new EdgeChromeStorageBridge() : undefined;
839 | this.tabs = typeof browser.tabs !== "undefined" ? new EdgeChromeTabsBridge() : undefined;
840 | this.webNavigation = typeof browser.webNavigation !== "undefined" ? new EdgeWebNavigationBridge() : undefined;
841 | this.webRequest = typeof browser.webRequest !== "undefined" ? new EdgeWebRequestBridge() : undefined;
842 | this.windows = typeof browser.windows !== "undefined" ? new EdgeChromeWindowsBridge() : undefined;
843 | }
844 | }
845 | var myBrowser = browser;
846 | var chrome = new EdgeBackgroundBridge();
847 |
--------------------------------------------------------------------------------