Refactor:Cleanup code
This commit is contained in:
@@ -7,7 +7,7 @@ window.pageURL="";
|
||||
window.clearkey="";
|
||||
|
||||
chrome.storage.local.get("isBlock", (value) => {
|
||||
window.isBlock = value.isBlock ? true : false;
|
||||
window.isBlock = value.isBlock;
|
||||
})
|
||||
|
||||
function convertHeaders(obj){
|
||||
@@ -18,11 +18,7 @@ window.blockRules = await fetch("blockRules.conf").then((r)=>r.text());
|
||||
blockRules = blockRules.replace(/\n^\s*$|\s*\/\/.*|\s*$/gm, "");
|
||||
blockRules = blockRules.split("\n");
|
||||
function testBlock(url) {
|
||||
if(window.isBlock){
|
||||
return blockRules.map(e => url.includes(e)).some(e=>e)
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
return window.isBlock && blockRules.map(e => url.includes(e)).some(e=>e);
|
||||
}
|
||||
|
||||
//Get URL and headers from POST requests
|
||||
@@ -99,7 +95,7 @@ chrome.runtime.onStartup.addListener(createMenu)
|
||||
chrome.contextMenus.onClicked.addListener(item => {
|
||||
if(item.menuItemId == "toggleBlocking"){
|
||||
chrome.storage.local.get("isBlock", (value) => {
|
||||
if(value.isBlock == true){
|
||||
if(value.isBlock){
|
||||
chrome.storage.local.set({'isBlock': false}, null);
|
||||
chrome.contextMenus.update("toggleBlocking",{title: "Enable License Blocking"})
|
||||
} else {
|
||||
|
||||
18
popup.js
18
popup.js
@@ -78,14 +78,12 @@ if (clearkey) {
|
||||
document.getElementById('ckResult').value = clearkey;
|
||||
document.getElementById('ckResult').addEventListener("click", copyResult);
|
||||
document.getElementById('toggleHistory').style.display = 'none'
|
||||
} else if (psshs.length != 0) {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
document.getElementById('noEME').style.display = 'none';
|
||||
document.getElementById('home').style.display = 'grid';
|
||||
document.getElementById('guess').addEventListener("click", guess);
|
||||
document.getElementById('result').addEventListener("click", copyResult);
|
||||
drawList(psshs, 'psshSearch', 'psshList', 'pssh');
|
||||
drawList(requests.map(r => r['url']), 'requestSearch', 'requestList', 'license');
|
||||
autoSelect();
|
||||
});
|
||||
} else if (psshs.length) {
|
||||
document.getElementById('noEME').style.display = 'none';
|
||||
document.getElementById('home').style.display = 'grid';
|
||||
document.getElementById('guess').addEventListener("click", guess);
|
||||
document.getElementById('result').addEventListener("click", copyResult);
|
||||
drawList(psshs, 'psshSearch', 'psshList', 'pssh');
|
||||
drawList(requests.map(r => r['url']), 'requestSearch', 'requestList', 'license');
|
||||
autoSelect();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ function backHistory(){
|
||||
document.getElementById('toggleHistory').style.display='grid';
|
||||
document.getElementById('selectRequest').style.display='none';
|
||||
document.getElementById('requestList').style.display='none';
|
||||
if(psshs.length != 0){
|
||||
if(psshs.length){
|
||||
document.getElementById('home').style.display='grid';
|
||||
} else {
|
||||
document.getElementById('noEME').style.display='grid';
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
document.addEventListener('DOMContentLoaded', async function() {
|
||||
cManifest=JSON.parse(
|
||||
(await fetch("manifest.json").then(r=>r.text()))
|
||||
);
|
||||
rManifest=JSON.parse(
|
||||
(await fetch("https://raw.githubusercontent.com/FoxRefire/wvg/next/manifest.json").then(r=>r.text()))
|
||||
);
|
||||
cManifest=await fetch("manifest.json").then(r=>r.json());
|
||||
rManifest=await fetch("https://raw.githubusercontent.com/FoxRefire/wvg/next/manifest.json").then(r=>r.json());
|
||||
if(cManifest.version < rManifest.version){
|
||||
let notice = document.getElementById("updateNotice");
|
||||
notice.style.display='block';
|
||||
|
||||
Reference in New Issue
Block a user