├── README.md
├── content.js
├── icon.png
├── manifest.json
├── options.html
└── options.js
/README.md:
--------------------------------------------------------------------------------
1 |
ClosedAI
2 | 
3 |
4 | ClosedAI is a Chrome/Firefox extension to replace instances of "OpenAI" with "ClosedAI" (or anything you like, just change it in extension options) all over the web.
5 |
6 | See also:
7 |
--------------------------------------------------------------------------------
/content.js:
--------------------------------------------------------------------------------
1 | const DEFAULT_REPLACEMENT = "ClosedAI";
2 |
3 | const walkDOMAndReplaceOpenAI = replacement => {
4 | const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_ALL, {
5 | acceptNode: node => {
6 | // Skip textarea.
7 | if ((node.tagName || "").toLowerCase() === "textarea") {
8 | return NodeFilter.FILTER_REJECT;
9 | }
10 | // Skip common web editors.
11 | if (
12 | node.classList &&
13 | (node.classList.contains("ace_editor") ||
14 | node.classList.contains("monaco-editor"))
15 | ) {
16 | return NodeFilter.FILTER_REJECT;
17 | }
18 | return NodeFilter.FILTER_ACCEPT;
19 | },
20 | });
21 | while ((node = walker.nextNode())) {
22 | if (node.nodeType === Node.TEXT_NODE) {
23 | node.nodeValue = node.nodeValue.replace(/\bOpenAI\b/g, replacement);
24 | }
25 | }
26 | };
27 |
28 | chrome.storage.sync.get(["replacement"], result => {
29 | const replacement = (result && result.replacement) || DEFAULT_REPLACEMENT;
30 | document.title = document.title.replace(/\bOpenAI\b/g, replacement);
31 | walkDOMAndReplaceOpenAI(replacement);
32 | });
33 |
--------------------------------------------------------------------------------
/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/clopen/ClosedAI/49b5eadba9513aa706ef0e1fe6b568032b105381/icon.png
--------------------------------------------------------------------------------
/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "manifest_version": 2,
3 | "name": "ClosedAI",
4 | "version": "1.0",
5 | "icons": {
6 | "128": "icon.png"
7 | },
8 | "permissions": ["storage"],
9 | "content_scripts": [
10 | {
11 | "matches": ["*://*/*"],
12 | "run_at": "document_end",
13 | "js": ["content.js"]
14 | }
15 | ],
16 | "options_ui": {
17 | "page": "options.html",
18 | "open_in_tab": false
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/options.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ClosedAI Options
5 |
10 |
11 |
12 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/options.js:
--------------------------------------------------------------------------------
1 | const DEFAULT_REPLACEMENT = "ClosedAI";
2 |
3 | const restoreOptions = () => {
4 | chrome.storage.sync.get(["replacement"], result => {
5 | document.getElementById("replacement").value =
6 | (result && result.replacement) || DEFAULT_REPLACEMENT;
7 | });
8 | };
9 |
10 | restoreOptions();
11 |
12 | document.getElementById("options").addEventListener("submit", event => {
13 | chrome.storage.sync.set(
14 | {
15 | replacement:
16 | document.getElementById("replacement").value.trim() ||
17 | DEFAULT_REPLACEMENT,
18 | },
19 | restoreOptions
20 | );
21 | event.preventDefault();
22 | });
23 |
--------------------------------------------------------------------------------