Minor tweaks. Fixed Unify Settings not working in chromium

This commit is contained in:
ManeraKai 2022-06-18 15:53:05 +03:00
parent a1e2b1867d
commit cb39680081
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337
4 changed files with 16 additions and 48 deletions

View File

@ -217,28 +217,6 @@ async function processDefaultCustomInstances(target, name, protocol, document) {
})
}
function getIp(href) {
return new Promise(resolve => {
let host = new URL(href).hostname;
let http = new XMLHttpRequest();
http.open("GET", `https://dns.google/resolve?name=${host}`, /*async*/true);
http.onreadystatechange = () => {
if (http.readyState == 4 && http.status == 200) {
let r = JSON.parse(http.responseText);
resolve(r.Answer[0].data)
}
};
http.ontimeout = () => resolve()
http.onerror = () => resolve()
try {
http.send(null)
}
catch (exception) {
resolve()
}
})
}
async function ping(href) {
return new Promise(async resolve => {
let http = new XMLHttpRequest();
@ -287,7 +265,7 @@ async function testLatency(element, instances) {
resolve(myList);
})
}
// Complete on getting cookies working in Tor, maybe delete all the other same name cookies to prevent overlapping, see ya :)
function copyCookie(frontend, targetUrl, urls, name) {
return new Promise(resolve => {
browser.storage.local.get('firstPartyIsolate', r => {
@ -311,19 +289,9 @@ function copyCookie(frontend, targetUrl, urls, name) {
url: url, name: name, value: cookie.value, secure: true,
expirationDate: cookie.expirationDate,
};
function removeCookie() {
return new Promise(resolve => {
const removeQuery = r.firstPartyIsolate ?
{ url: url, name: name, firstPartyDomain: new URL(url).hostname }
:
{ url: url, name: name };
browser.cookies.remove(removeQuery, resolve)
})
}
while (await removeCookie() != null) continue;
browser.cookies.set(setQuery, () => {
browser.cookies.set(setQuery, () =>
browser.storage.local.set({ [`${frontend}_${name}`]: cookie }, () => resolve())
});
);
}
break;
}

View File

@ -456,20 +456,20 @@ function removeXFrameOptions(e) {
isChanged = true;
}
}
if (isChanged) return { responseHeaders: e.responseHeaders };
}
else if (e.type == 'sub_frame') {
const url = new URL(e.url);
const protocolHost = utils.protocolHost(url);
if (!all().includes(protocolHost)) return;
for (const i in e.responseHeaders) {
if (e.responseHeaders[i].name == 'x-frame-options') {
e.responseHeaders.splice(i, 1);
isChanged = true;
}
else if (e.responseHeaders[i].name == 'content-security-policy') {
e.responseHeaders.splice(i, 1);
isChanged = true;
if (all().includes(protocolHost)) {
for (const i in e.responseHeaders) {
if (e.responseHeaders[i].name == 'x-frame-options') {
e.responseHeaders.splice(i, 1);
isChanged = true;
}
else if (e.responseHeaders[i].name == 'content-security-policy') {
e.responseHeaders.splice(i, 1);
isChanged = true;
}
}
}
}

View File

@ -66,7 +66,7 @@
"suggested_key": {
"default": "Alt+Shift+C"
},
"description": "Copies the original link. Ex: Copies the original twitter link when in while nitter website"
"description": "Copies the original link. Ex: Copies the original twitter link while in the nitter website"
},
"unify": {
"suggested_key": {

View File

@ -171,8 +171,8 @@ browser.tabs.onRemoved.addListener(
browser.webRequest.onHeadersReceived.addListener(
e => {
let response = twitterHelper.removeXFrameOptions(e);
if (!response) response = youtubeHelper.removeXFrameOptions(e);
let response = youtubeHelper.removeXFrameOptions(e);
if (!response) response = twitterHelper.removeXFrameOptions(e);
return response;
},
{ urls: ["<all_urls>"] },