Created
June 10, 2020 06:58
-
-
Save jeantimex/050d3a37a84ad8acf1b7a6a414643acc to your computer and use it in GitHub Desktop.
Simple Chrome extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var toggle = false; | |
chrome.browserAction.onClicked.addListener(function (tab) { | |
toggle = !toggle; | |
if (toggle){ | |
// chrome.browserAction.setIcon({path: "on.png", tabId:tab.id}); | |
chrome.tabs.executeScript(tab.id, {file: "color-picker.js"}); | |
} else { | |
//chrome.browserAction.setIcon({path: "off.png", tabId:tab.id}); | |
//chrome.tabs.executeScript(tab.id, {code: "alert('hello')"}); | |
chrome.tabs.executeScript(tab.id, {file: "quit.js"}); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
const div = document.createElement('div'); | |
div.id = 'jeantimex'; | |
div.innerHTML = 'test'; | |
document.body.appendChild(div); | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Append Test Text", | |
"description": "Add test123 to body", | |
"version": "1.0", | |
"permissions": [ | |
"activeTab" | |
], | |
"background": { | |
"scripts": ["background.js"] | |
}, | |
"browser_action": { | |
"default_title": "Append Test Text" | |
}, | |
"manifest_version": 2 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
const div = document.querySelector('#jeantimex'); | |
if (div) { | |
div.remove(); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment