initial commit
This commit is contained in:
commit
e3a5ae7528
7 changed files with 105 additions and 0 deletions
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2023 Jannis
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
52
bg.js
Normal file
52
bg.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
//Returns the hostname of the active tab
|
||||
async function GetHostname() {
|
||||
var tabs = await browser.tabs.query({active: true, currentWindow: true});
|
||||
var hostname = new URL(tabs[0].url).hostname;
|
||||
return hostname;
|
||||
}
|
||||
|
||||
//Changes the state of save
|
||||
async function ToggleSaveState()
|
||||
{
|
||||
var saveState = await QuerySaveState();
|
||||
var hostName = await GetHostname();
|
||||
if(saveState) {
|
||||
browser.storage.local.set({[hostName]:false});
|
||||
}
|
||||
else {
|
||||
browser.storage.local.set({[hostName]:hostName});
|
||||
}
|
||||
ChangeIcon(!saveState);
|
||||
}
|
||||
|
||||
//Returns the save state
|
||||
async function QuerySaveState()
|
||||
{
|
||||
var hostName = await GetHostname();
|
||||
var res = await browser.storage.local.get(hostName);
|
||||
if(res[hostName] == undefined || res[hostName] == false) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//Changes the icon of the extension
|
||||
async function ChangeIcon(pBool)
|
||||
{
|
||||
if(pBool)
|
||||
browser.browserAction.setIcon({path: "icons/icon-32.png"});
|
||||
else
|
||||
browser.browserAction.setIcon({path: "icons/icon-32-r.png"});
|
||||
}
|
||||
function ChangeIconOnQuerySaveState() {
|
||||
QuerySaveState().then((res) => {ChangeIcon(res)});
|
||||
}
|
||||
|
||||
|
||||
browser.browserAction.onClicked.addListener(ToggleSaveState);
|
||||
browser.tabs.onUpdated.addListener(ChangeIconOnQuerySaveState);
|
||||
browser.tabs.onActivated.addListener(ChangeIconOnQuerySaveState);
|
||||
browser.windows.onFocusChanged.addListener(ChangeIconOnQuerySaveState);
|
||||
ChangeIconOnQuerySaveState();
|
BIN
icons/icon-32-r.png
Normal file
BIN
icons/icon-32-r.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 625 B |
BIN
icons/icon-32.png
Normal file
BIN
icons/icon-32.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 610 B |
BIN
icons/icon-48.png
Normal file
BIN
icons/icon-48.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
BIN
icons/icon-96.png
Normal file
BIN
icons/icon-96.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
32
manifest.json
Normal file
32
manifest.json
Normal file
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "M4rked",
|
||||
"version": "1.0",
|
||||
|
||||
"description": "Allows users to mark domains, and will show if the domain isnt marked.",
|
||||
|
||||
"icons": {
|
||||
"48": "icons/icon-48.png",
|
||||
"96": "icons/icon-96.png"
|
||||
},
|
||||
|
||||
"permissions": [
|
||||
"activeTab",
|
||||
"tabs",
|
||||
"storage"
|
||||
],
|
||||
|
||||
"browser_action": {
|
||||
"default_icon": "icons/icon-32.png",
|
||||
"default_title": "DomProt"
|
||||
},
|
||||
|
||||
"background": {
|
||||
"scripts": ["bg.js"]
|
||||
},
|
||||
|
||||
"author": "Booklordofthedings"
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue