fixup the links replacer

This commit is contained in:
idk
2020-10-12 01:19:50 -04:00
parent 105aaed014
commit fa0aedda92
4 changed files with 64 additions and 3 deletions

View File

@@ -97,10 +97,11 @@ Usage:
console URL's and placing applications under their own origin.
* ![Visiting routerconsole](routerconsole.png)
* [Done] **Handle Torrents** by talking to i2psnark-rpc plugin and then
adding them directly into the Firefox downloads drop-downs, menus, etc. If I
can.
adding them directly into the Firefox downloads drop-downs, menus, etc. Enable
the use of I2PSnark as a peer-to-peer delivery mechanism for media files.
* ![Visiting i2psnark](i2psnark.png)
* ![Monitoring torrents](transmissionrpc.png)
* ![Distribute your site as a torrent.](x-i2p-torrentlocation.png)
* [Started] **Indicate** the level of authenticity provided by TLS. TLS is
optional on I2P for now, but some sites offer it anyway. TLS support is
experimental and in the works.

View File

@@ -35,6 +35,36 @@ browser.runtime.onMessage.addListener(request => {
};
}
}
var links = document.getElementsByTagName('a');
console.log('Listing link', links);
for (let link of links) {
console.log('(Changing Link)', link);
let tmpsrc = new URL(link.href);
// console.log("link", tmpsrc.host, tmpsrc.pathname)
if (tmpsrc.host == location.host) {
if (!tmpsrc.pathname.endsWith('html') && !tmpsrc.pathname.endsWith('htm') &&
!tmpsrc.pathname.endsWith('php') && !tmpsrc.pathname.endsWith('jsp') &&
!tmpsrc.pathname.endsWith('asp') && !tmpsrc.pathname.endsWith('aspx') &&
!tmpsrc.pathname.endsWith('atom') && !tmpsrc.pathname.endsWith('rss') &&
!tmpsrc.pathname.endsWith('\/') && tmpsrc.pathname.includes('.')) {
console.log('link', tmpsrc.host, tmpsrc.pathname);
link.href = 'http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;
link.onerror = function() {
window.location.href = tmpsrc.href;
};
}
//if (!tmpsrc.pathname.endsWith('html')) { // && !tmpsrc.pathname.endsWith('htm') &&
// !tmpsrc.pathname.endsWith('php') && !tmpsrc.pathname.endsWith('jsp') &&
// !tmpsrc.pathname.endsWith('asp') && !tmpsrc.pathname.endsWith('aspx') &&
// tmpsrc.pathname.includes('.') && !tmpsrc..pathname.endsWith('/')) {
//console.log('http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;)
//link.href = 'http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;
//link.onerror = function() {
//link.src = tmpsrc;
//};
//}
}
}
var videos = document.getElementsByTagName('video');
for (let video of videos) {
let tmpsrc = new URL(video.currentSrc);
@@ -62,6 +92,7 @@ browser.runtime.onMessage.addListener(request => {
response = metas[i].getAttribute('content');
var imgs = document.getElementsByTagName('img');
for (let img of imgs) {
let tmpsrc = new URL(img.src);
if (tmpsrc.host == location.host) {
img.src = 'http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;
img.onerror = function() {
@@ -69,6 +100,36 @@ browser.runtime.onMessage.addListener(request => {
};
}
}
var links = document.getElementsByTagName('a');
console.log('Listing link', links);
for (let link of links) {
console.log('(Changing Link)', link);
let tmpsrc = new URL(link.href);
//console.log("link", tmpsrc.host, tmpsrc.pathname)
if (tmpsrc.host == location.host) {
if (!tmpsrc.pathname.endsWith('html') && !tmpsrc.pathname.endsWith('htm') &&
!tmpsrc.pathname.endsWith('php') && !tmpsrc.pathname.endsWith('jsp') &&
!tmpsrc.pathname.endsWith('asp') && !tmpsrc.pathname.endsWith('aspx') &&
!tmpsrc.pathname.endsWith('atom') && !tmpsrc.pathname.endsWith('rss') &&
!tmpsrc.pathname.endsWith('\/') && tmpsrc.pathname.includes('.')) {
console.log('link', tmpsrc.host, tmpsrc.pathname);
link.href = 'http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;
link.onerror = function() {
window.location.href = tmpsrc.href;
};
}
//if (!tmpsrc.pathname.endsWith('html')) { // && !tmpsrc.pathname.endsWith('htm') &&
// !tmpsrc.pathname.endsWith('php') && !tmpsrc.pathname.endsWith('jsp') &&
// !tmpsrc.pathname.endsWith('asp') && !tmpsrc.pathname.endsWith('aspx') &&
// tmpsrc.pathname.includes('.') && !tmpsrc..pathname.endsWith('/')) {
//console.log('http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;)
//link.href = 'http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;
//link.onerror = function() {
//link.src = tmpsrc;
//};
//}
}
}
var videos = document.getElementsByTagName('video');
for (let video of videos) {
let tmpsrc = new URL(video.currentSrc);

View File

@@ -753,7 +753,6 @@ function getClearTab(tobj) {
console.log("(pageaction)", tab.id, tab.url)
}
}
console.log(tobj)
if (typeof(tobj) == "number"){
browser.tabs.get(tobj).then(getTabURL, onError)
}else{

BIN
x-i2p-torrentlocation.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 KiB