fix btProxy

This commit is contained in:
idk
2020-12-09 21:58:58 -05:00
parent a6aba7b5f7
commit 3a30961cd1
2 changed files with 62 additions and 5 deletions

View File

@@ -52,7 +52,11 @@ var handleContextProxyRequest = async function(requestDetails) {
host: getHost(),
port: getPort(),
};
let url = new URL(requestDetails.url);
console.log('(proxy) URL', url);
if (requestDetails.url.includes('/i2psnark/')) {
//+url.host)) {
console.log('(proxy) URL 2', url);
proxy = null;
}
return proxy;

View File

@@ -3,18 +3,59 @@ browser.runtime.onMessage.addListener((request) => {
console.log(request);
if (request.req === 'i2p-location') {
var tag = document.querySelector('meta[http-equiv="i2p-location"]');
console.log(tag);
if (tag) response = tag.content;
if (tag != undefined) {
console.log(tag);
if (tag) response = tag.content;
}
var tag = document.querySelector('meta[http-equiv="x-i2p-location"]');
if (tag != undefined) {
console.log(tag);
if (tag) response = tag.content;
}
}
if (request.req === 'i2p-torrentlocation') {
const metas = document.getElementsByTagName('meta');
var tag = document.querySelector('meta[http-equiv="i2p-torrentlocation"]');
console.log(tag);
response = i2pTorrent(tag);
if (tag != undefined) {
console.log(tag);
response = i2pTorrent(tag);
}
var tag = document.querySelector(
'meta[http-equiv="x-i2p-torrentlocation"]'
);
if (tag != undefined) {
console.log(tag);
response = i2pTorrent(tag);
}
}
return Promise.resolve({ content: response });
});
window.document.onload = function (e) {
console.log("presetting x-i2p-torrentlocation");
var tag = document.querySelector('meta[http-equiv="i2p-torrentlocation"]');
if (tag != undefined) {
console.log(tag);
response = i2pTorrent(tag);
}
var tag = document.querySelector('meta[http-equiv="x-i2p-torrentlocation"]');
if (tag != undefined) {
console.log(tag);
response = i2pTorrent(tag);
}
};
console.log("presetting x-i2p-torrentlocation");
var tag = document.querySelector('meta[http-equiv="i2p-torrentlocation"]');
if (tag != undefined) {
console.log(tag);
response = i2pTorrent(tag);
}
var tag = document.querySelector('meta[http-equiv="x-i2p-torrentlocation"]');
if (tag != undefined) {
console.log(tag);
response = i2pTorrent(tag);
}
function i2pTorrent(tag) {
let response = "no-alt-location";
if (tag) {
@@ -42,8 +83,14 @@ function i2pTorrent(tag) {
'src="',
'src="http://127.0.0.1:7657/i2psnark/' + location.host + "/"
);
// let url = new URL("http://127.0.0.1:7657/i2psnark/"+location.host+"/"location.path)
console.log(
"http://127.0.0.1:7657/i2psnark/" + tmpsrc.host + tmpsrc.pathname
); //+"/"location.path)
//video.src = "http://127.0.0.1:7657/i2psnark/"+location.replace("http://")
video.innerHTML = topInnerHTML; // + innerHTML;
video.onerror = function () {
console.log("video error");
video.innerHTML = topInnerHTML + innerHTML;
};
}
@@ -60,8 +107,14 @@ function i2pTorrent(tag) {
'src="',
'src="http://127.0.0.1:7657/i2psnark/' + location.host + "/"
);
//console.log("http://127.0.0.1:7657/i2psnark/" + location); //.host+"/"location.path)
console.log(
"http://127.0.0.1:7657/i2psnark/" + tmpsrc.host + tmpsrc.pathname
); //+"/"location.path)
//audio.src = "http://127.0.0.1:7657/i2psnark/"+location.replace("http://")
audio.innerHTML = topInnerHTML; // + innerHTML;
audio.onerror = function () {
console.log("audio error");
audio.innerHTML = topInnerHTML + innerHTML;
};
}