Replace CloudFlare links

Take action against CloudFlare. Replace CloudFlare links.

当前为 2023-12-15 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Replace CloudFlare links
  3. // @description Take action against CloudFlare. Replace CloudFlare links.
  4. // @namespace deCloudflare_us_replace-cf
  5. // @author Matthew L. Tanner, CrimeFlare
  6. // @match https://*/*
  7. // @match http://*/*
  8. // @version 1.0.0.1
  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 fqdns = {},
  21. fqdn_self = location.hostname;
  22. function mark_fqdn(fl) {
  23. try {
  24. if (fl == '') {
  25. return;
  26. }
  27. fetch(api_url, {
  28. method: 'POST',
  29. mode: 'cors',
  30. body: 'ff=' + fl,
  31. referrer: '',
  32. headers: {
  33. 'Content-Type': 'application/x-www-form-urlencoded'
  34. }
  35. }).then(x => x.json()).then(x => {
  36. for (let xx in x) {
  37. if (fqdns[xx]) {
  38. if (x[xx]) {
  39. fqdns[xx].forEach(qs => {
  40. qs.setAttribute('xcf', 'y');
  41. qs.href = 'https://web.archive.org/web/' + qs.href;
  42. });
  43. } else {
  44. fqdns[xx].forEach(qs => {
  45. qs.setAttribute('xcf', 'n');
  46. });
  47. }
  48. delete fqdns[xx];
  49. }
  50. }
  51. }).catch(x => {});
  52. } catch (x) {}
  53. }
  54. if (!DONT_RUN_FQDNS.includes(fqdn_self) && !/\.crimeflare\.eu\.org$/.test(fqdn_self)) {
  55. try {
  56. const style = document.createElement('style');
  57. document.head.appendChild(style);
  58. const styleSheet = style.sheet;
  59. 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);
  60. } catch (x) {}
  61. document.querySelectorAll('a[href]:not([xcf])').forEach(l => {
  62. try {
  63. let u = new URL(l.href);
  64. if (u.hostname != fqdn_self && (u.protocol == 'https:' || u.protocol == 'http:')) {
  65. let fqdn = u.hostname;
  66. if (fqdns[fqdn] == undefined) {
  67. fqdns[fqdn] = [];
  68. }
  69. if (!/^(|(.*)\.)archive\.org$/.test(fqdn)) {
  70. fqdns[fqdn].push(l);
  71. }
  72. l.setAttribute('xcf', 'q');
  73. }
  74. } catch (x) {}
  75. });
  76. mark_fqdn(Object.keys(fqdns).slice(0,200).join(','));
  77. }