deCloudflare/tool/userscripts/cf.color.user.js

82 lines
2.6 KiB
JavaScript
Raw Permalink Normal View History

2023-12-14 04:34:17 -05:00
// ==UserScript==
// @name Mark CloudFlare links
2023-12-14 18:45:59 -05:00
// @description Take action against CloudFlare. Mark CloudFlare links.
2023-12-14 04:34:17 -05:00
// @namespace deCloudflare_us_color-cf
2023-12-14 04:53:17 -05:00
// @author Matthew L. Tanner, CrimeFlare
2023-12-14 04:34:17 -05:00
// @match https://*/*
// @match http://*/*
2023-12-14 20:23:10 -05:00
// @version 1.0.0.2
2023-12-14 04:34:17 -05:00
// @grant none
// @run-at document-end
// @license MIT
// ==/UserScript==
// this script will not run on those sites
// e.g. ['www.youtube.com','www.google.com']
2023-12-14 18:32:26 -05:00
let DONT_RUN_FQDNS = ['web.archive.org'];
2023-12-14 04:34:17 -05:00
//-----
// [Documentation] https://0xacab.org/dCF/deCloudflare/-/blob/master/tool/userscripts/README.md
// [About API] http://about-karmaapi.go.crimeflare.eu.org
const api_url = 'https://karma.crimeflare.eu.org/api/is/cloudflare/';
2023-12-14 20:23:10 -05:00
let fqdn_self = location.hostname;
function scanme() {
let fqdns = {};
document.querySelectorAll('a[href]:not([xcf])').forEach(l => {
try {
let u = new URL(l.href);
if (u.hostname != fqdn_self && (u.protocol == 'https:' || u.protocol == 'http:')) {
l.setAttribute('xcf', 'q');
let fqdn = u.hostname;
if (!/^(|(.*)\.)archive\.org$/.test(fqdn)) {
2023-12-14 20:39:27 -05:00
if (fqdns[fqdn] == undefined) {
fqdns[fqdn] = [];
}
2023-12-14 20:23:10 -05:00
fqdns[fqdn].push(l);
}
}
} catch (x) {}
});
let ff_str = Object.keys(fqdns).slice(0, 200).join(',');
if (ff_str == '') {
return;
}
2023-12-14 04:34:17 -05:00
try {
fetch(api_url, {
method: 'POST',
mode: 'cors',
2023-12-14 20:23:10 -05:00
body: 'ff=' + ff_str,
2023-12-14 04:34:17 -05:00
referrer: '',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).then(x => x.json()).then(x => {
for (let xx in x) {
if (fqdns[xx]) {
if (x[xx]) {
fqdns[xx].forEach(qs => {
qs.setAttribute('xcf', 'y');
});
} else {
fqdns[xx].forEach(qs => {
qs.setAttribute('xcf', 'n');
});
}
}
}
}).catch(x => {});
} catch (x) {}
}
if (!DONT_RUN_FQDNS.includes(fqdn_self) && !/\.crimeflare\.eu\.org$/.test(fqdn_self)) {
try {
const style = document.createElement('style');
document.head.appendChild(style);
const styleSheet = style.sheet;
2023-12-14 18:32:26 -05:00
styleSheet.insertRule("a[xcf='y']{opacity:0.6;text-decoration-line:line-through !important;text-decoration-color:red !important;text-decoration-style:double !important;}", 0);
2023-12-14 04:34:17 -05:00
} catch (x) {}
2023-12-14 20:23:10 -05:00
scanme();
(new MutationObserver(scanme)).observe(document, {
attributes: true,
attributeFilter: ['href'],
childList: true,
subtree: true
2023-12-14 04:34:17 -05:00
});
}