wings.io Patches

| Dark Mode | Profanity Filter | and more... patches are designed to run on load, make required edits and reload

当前为 2024-11-14 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name wings.io Patches
  3. // @namespace http://tampermonkey.net/
  4. // @version 3.8-(14/Nov/2024)
  5. // @description | Dark Mode | Profanity Filter | and more... patches are designed to run on load, make required edits and reload
  6. // @author ⟐Ragav
  7. // @icon https://wings.io/images/favicon.png
  8. // @match https://wings.io/
  9. // @match https://wings.io/#*
  10. // @run-at document-start
  11. // @grant GM_getResourceText
  12. // @require https://raw.githubusercontent.com/google/diff-match-patch/cd60d246aecf871367313c7cf6dc8814af32c5e3/javascript/diff_match_patch.js#sha256=d422c483b926ca7cea768a03c8f0f26ebc69d5041e3deb550d2709dd40fa16ea
  13. // @resource default_profanity_blacklist https://raw.githubusercontent.com/mogade/badwords/refs/heads/master/en.txt
  14. // @resource wingsio_index_pаge https://wings.io/
  15. // @resource wingsio_index_page https://gw6mc32y.pages.dev/source/index.html#sha256=b47f7772b08ff125efc1293526993b9ad50729f8a1e42fd1d92c2d5e13f526e8
  16. // @resource feat-dark-theme https://gw6mc32y.pages.dev/patches/feat-dark-theme/patch.diff#sha256=d27f248fba284a0d257000ce7219954b0905c862139a7f42067e4089b2f42520
  17. // @resource feat-profanity-filter https://gw6mc32y.pages.dev/patches/feat-profanity-filter/patch.diff#sha256=69e9f1ef323baeb8aac7568ad9e430469def3319442b1e4f60380bd23dde41e8
  18. // @resource feat-server-ping https://gw6mc32y.pages.dev/patches/feat-server-ping/patch.diff#sha256=474e4e5d0a1a8a4e1c330a55f5ab5f3b7f7913b1dacd35630e1bcf96f62c26ad
  19. // @resource mod-always-show-nickinput https://gw6mc32y.pages.dev/patches/mod-always-show-nickinput/patch.diff#sha256=e9ace3789b4fd92b32878e7bc2ba382ce9465d9cba0bcff5e7bc07d199553983
  20. // @resource mod-colorful-trail https://gw6mc32y.pages.dev/patches/mod-colorful-trail/patch.diff#sha256=6219cbf04c55b814502f98f4a7a11e0b08703d1661cb5356774521be598b0fa6
  21. // @resource mod-disable-shake https://gw6mc32y.pages.dev/patches/mod-disable-shake/patch.diff#sha256=e75676367ef61ec6ca486831335c839c23a086b412a3906f7e5c7057a35772d5
  22. // @resource mod-mark-bots-with-color https://gw6mc32y.pages.dev/patches/mod-mark-bots-with-color/patch.diff#sha256=5815ad548fee2bf94bced7ebef45e00b170bf00826bd6a43cad50411a7a95d53
  23. // @resource mod-mark-bots-with-emoji https://gw6mc32y.pages.dev/patches/mod-mark-bots-with-emoji/patch.diff#sha256=44df21c987f4d68f46a8a0b076ca91a83119ce600d079c54b00f4d925e71c406
  24. // @resource mod-remove-leaderboard-limit https://gw6mc32y.pages.dev/patches/mod-remove-leaderboard-limit/patch.diff#sha256=1543dfd89d2517af4aace201addb57fdd8d2f11559d8295422040f7fb5f32863
  25. // @license AGPL-3.0-or-later
  26. // ==/UserScript==
  27.  
  28. (function () {
  29. // EDITABLE REGION
  30.  
  31. // Comment to disable patch
  32. const patches = [
  33. 'feat-dark-theme',
  34. 'feat-profanity-filter',
  35. 'feat-server-ping',
  36. // 'mod-always-show-nickinput',
  37. // 'mod-colorful-trail',
  38. // 'mod-disable-shake',
  39. // 'mod-mark-bots-with-color',
  40. // 'mod-mark-bots-with-emoji',
  41. // 'mod-remove-leaderboard-limit',
  42. ];
  43.  
  44. const settings = {
  45. profanity_filter_character: "✲",
  46. debug_profanity_filter_show_filtered: false,
  47. }
  48.  
  49. const profanity_regex_blacklist = [
  50.  
  51. ...(GM_getResourceText('default_profanity_blacklist').split("\n")),
  52. ];
  53. const profanity_regex_whitelist = [
  54.  
  55. ];
  56. // END OF EDITABLE REGION
  57.  
  58. const profanity_filter_extension = `
  59. let profanity_regex_blacklist=\`${profanity_regex_blacklist.toString()}\`.split(',').filter(str => str.length > 0);
  60. let profanity_regex_whitelist=\`${profanity_regex_whitelist.toString()}\`.split(',').filter(str => str.length > 0);
  61. const debug_show_filtered_profanity=${settings.debug_profanity_filter_show_filtered};
  62.  
  63. profanity_regex_blacklist = profanity_regex_blacklist.map(regex_str => new RegExp(regex_str, 'ig'));
  64. profanity_regex_whitelist = profanity_regex_whitelist.map(regex_str => new RegExp(regex_str, 'ig'));
  65. function filter_name(name) {
  66. for (const regex_block of profanity_regex_blacklist) {
  67. name = name.replaceAll(new RegExp(regex_block, 'ig'), match=>{
  68. for(const regex_allow of profanity_regex_whitelist) {
  69. if(match.search(regex_allow) > -1) return match;
  70. }
  71. return '${settings.profanity_filter_character}'.repeat(match.length) + (debug_show_filtered_profanity ? ' ('+match+')' : '');
  72. })
  73. }
  74. return name;
  75. };`;
  76.  
  77. function getPatchedPage() {
  78. const dmp = new diff_match_patch();
  79. dmp.Match_Distance = Infinity;
  80.  
  81. let result, str_html = GM_getResourceText("wingsio_index_page");
  82.  
  83. let list_patches = [];
  84. for(const patch of patches) list_patches.push(...(dmp.patch_fromText(GM_getResourceText(patch))));
  85.  
  86. [str_html, result] = dmp.patch_apply(list_patches, str_html);
  87. if(patches.includes('feat-profanity-filter')) str_html = str_html.replace('(function(w,x,s){', profanity_filter_extension+'(function(w,x,s){');
  88.  
  89. console.log(result.every(Boolean) ? 'All patches applied successfully' : 'Failed to apply some patches');
  90.  
  91. return str_html;
  92. }
  93.  
  94. var observer = new MutationObserver(mutationRecords => {
  95. mutationRecords.every( record => {
  96. if (record.addedNodes[0]) {
  97. observer.disconnect();
  98. document.write(getPatchedPage());
  99. document.close();
  100. return false
  101. }
  102. return true
  103. })
  104. });
  105.  
  106. observer.observe(document, {
  107. childList: true,
  108. subtree: true
  109. });
  110. })();