Add no-referrer
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name EH Gallery Script
|
// @name EH Gallery Script
|
||||||
// @namespace https://github.com/lifegpc/userscript
|
// @namespace https://github.com/lifegpc/userscript
|
||||||
// @version 0.1.6
|
// @version 0.1.7
|
||||||
// @description :(
|
// @description :(
|
||||||
// @author lifegpc
|
// @author lifegpc
|
||||||
// @match https://*.e-hentai.org/g/*/*
|
// @match https://*.e-hentai.org/g/*/*
|
||||||
@@ -53,12 +53,14 @@ let need_reinit = false;
|
|||||||
let storage = navigator.storage || globalThis['WorkerNavigator']['storage'];
|
let storage = navigator.storage || globalThis['WorkerNavigator']['storage'];
|
||||||
const BLACK_LIST_HOST = [
|
const BLACK_LIST_HOST = [
|
||||||
"tva1.sinaimg.cn",
|
"tva1.sinaimg.cn",
|
||||||
"img.moegirl.org.cn",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
function filter_html(html) {
|
function filter_html(html) {
|
||||||
let doc = (new DOMParser).parseFromString(html, "text/html");
|
let doc = (new DOMParser).parseFromString(html, "text/html");
|
||||||
doc.querySelectorAll('a').forEach(a => a.setAttribute('target', '_blank'));
|
doc.querySelectorAll('a').forEach((a) => {
|
||||||
|
a.target = "_blank";
|
||||||
|
a.referrerPolicy = "no-referrer";
|
||||||
|
});
|
||||||
doc.querySelectorAll('img[src="#"]').forEach((img) => {
|
doc.querySelectorAll('img[src="#"]').forEach((img) => {
|
||||||
let title = img.title;
|
let title = img.title;
|
||||||
try {
|
try {
|
||||||
@@ -75,7 +77,10 @@ function filter_html(html) {
|
|||||||
if (BLACK_LIST_HOST.includes(u.host)) {
|
if (BLACK_LIST_HOST.includes(u.host)) {
|
||||||
console.log("Remove blacklist URL: ", u.toString());
|
console.log("Remove blacklist URL: ", u.toString());
|
||||||
img.remove();
|
img.remove();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
img.referrerPolicy = "no-referrer";
|
||||||
|
img.style.maxWidth = "380px";
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
})
|
})
|
||||||
return doc.body.innerHTML;
|
return doc.body.innerHTML;
|
||||||
@@ -94,6 +99,7 @@ function filter_html2(html) {
|
|||||||
})
|
})
|
||||||
doc.querySelectorAll('img').forEach((img) => {
|
doc.querySelectorAll('img').forEach((img) => {
|
||||||
img.style.height = "12px";
|
img.style.height = "12px";
|
||||||
|
img.referrerPolicy = "no-referrer";
|
||||||
})
|
})
|
||||||
return doc.body.innerHTML;
|
return doc.body.innerHTML;
|
||||||
}
|
}
|
||||||
@@ -280,7 +286,7 @@ GM_config.init({
|
|||||||
enableTagTranslation: {
|
enableTagTranslation: {
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
label: 'Enable tag translation.',
|
label: 'Enable tag translation.',
|
||||||
default: false
|
default: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
|
|||||||
Reference in New Issue
Block a user