cf.remove.user.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // ==UserScript==
  2. // @name Remove CloudFlare links
  3. // @description Take action against CloudFlare. Remove CloudFlare links.
  4. // @namespace deCloudflare_us_remove-cf
  5. // @author Matthew L. Tanner, CrimeFlare
  6. // @match https://*/*
  7. // @match http://*/*
  8. // @version 1.0.0.2
  9. // @grant none
  10. // @run-at document-end
  11. // @license MIT
  12. // ==/UserScript==
  13. // this script will not run on those sites
  14. // e.g. ['www.youtube.com','www.google.com']
  15. let DONT_RUN_FQDNS = ['web.archive.org'];
  16. //-----
  17. // [Documentation] https://0xacab.org/dCF/deCloudflare/-/blob/master/tool/userscripts/README.md
  18. // [About API] http://about-karmaapi.go.crimeflare.eu.org
  19. const api_url = 'https://karma.crimeflare.eu.org/api/is/cloudflare/';
  20. let fqdn_self = location.hostname;
  21. function scanme() {
  22. let fqdns = {};
  23. document.querySelectorAll('a[href]:not([xcf])').forEach(l => {
  24. try {
  25. let u = new URL(l.href);
  26. if (u.hostname != fqdn_self && (u.protocol == 'https:' || u.protocol == 'http:')) {
  27. l.setAttribute('xcf', 'q');
  28. let fqdn = u.hostname;
  29. if (!/^(|(.*)\.)archive\.org$/.test(fqdn)) {
  30. if (fqdns[fqdn] == undefined) {
  31. fqdns[fqdn] = [];
  32. }
  33. fqdns[fqdn].push(l);
  34. }
  35. }
  36. } catch (x) {}
  37. });
  38. let ff_str = Object.keys(fqdns).slice(0, 200).join(',');
  39. if (ff_str == '') {
  40. return;
  41. }
  42. try {
  43. fetch(api_url, {
  44. method: 'POST',
  45. mode: 'cors',
  46. body: 'ff=' + ff_str,
  47. referrer: '',
  48. headers: {
  49. 'Content-Type': 'application/x-www-form-urlencoded'
  50. }
  51. }).then(x => x.json()).then(x => {
  52. for (let xx in x) {
  53. if (fqdns[xx]) {
  54. if (x[xx]) {
  55. fqdns[xx].forEach(qs => {
  56. qs.outerHTML = qs.innerHTML;
  57. });
  58. } else {
  59. fqdns[xx].forEach(qs => {
  60. qs.setAttribute('xcf', 'n');
  61. });
  62. }
  63. }
  64. }
  65. }).catch(x => {});
  66. } catch (x) {}
  67. }
  68. if (!DONT_RUN_FQDNS.includes(fqdn_self) && !/\.crimeflare\.eu\.org$/.test(fqdn_self)) {
  69. scanme();
  70. (new MutationObserver(scanme)).observe(document, {
  71. attributes: true,
  72. attributeFilter: ['href'],
  73. childList: true,
  74. subtree: true
  75. });
  76. }