wings.io Patches

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

当前为 2024-10-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name wings.io Patches
  3. // @namespace http://tampermonkey.net/
  4. // @version 3.2-(24/Oct/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 wingsio_index_html https://wings.io#sha256=b47f7772b08ff125efc1293526993b9ad50729f8a1e42fd1d92c2d5e13f526e8
  14. // @resource wingsio_index_html_archive https://raw.githubusercontent.com/ragavpr/overrides-wings.io/1a053b9883321a704b64d4aff5a6ee59056d9643/index.html#sha256=b47f7772b08ff125efc1293526993b9ad50729f8a1e42fd1d92c2d5e13f526e8
  15. // @resource default_profanity_blacklist https://raw.githubusercontent.com/mogade/badwords/refs/heads/master/en.txt
  16. // @resource patch_dark_theme https://raw.githubusercontent.com/ragavpr/overrides-wings.io/64f94d68c8414da4f5a198d5b54e11cc5b89ee23/diff.patch#sha256=35e84754d59ca2256588150fe1a0de3e5bc28eeb8fc6ba2977089addb1f3e322
  17. // @resource patch_profanity_filter https://raw.githubusercontent.com/ragavpr/overrides-wings.io/d31bc08e9e58d80f59040dba60cfe7509670b1b4/diff.patch#sha256=69e9f1ef323baeb8aac7568ad9e430469def3319442b1e4f60380bd23dde41e8
  18. // @resource patch_always_show_nick_input https://raw.githubusercontent.com/ragavpr/overrides-wings.io/0eecd1bca75895c9b96346afee2c0600a432439e/diff.patch#sha256=e9ace3789b4fd92b32878e7bc2ba382ce9465d9cba0bcff5e7bc07d199553983
  19. // @resource patch_disable_shake https://raw.githubusercontent.com/ragavpr/overrides-wings.io/d056e52894b7a5574391d5e1362ad8930112ec02/diff.patch#sha256=e75676367ef61ec6ca486831335c839c23a086b412a3906f7e5c7057a35772d5
  20. // @resource patch_mark_bots_with_emoji https://raw.githubusercontent.com/ragavpr/overrides-wings.io/33266812371cd9c631d0c00a4ec1071243c96834/diff.patch#sha256=44df21c987f4d68f46a8a0b076ca91a83119ce600d079c54b00f4d925e71c406
  21. // @resource patch_mark_bots_with_color https://raw.githubusercontent.com/ragavpr/overrides-wings.io/13c83c7ea7d81ef34c8b62fa01b339d410f74f02/diff.patch#sha256=5815ad548fee2bf94bced7ebef45e00b170bf00826bd6a43cad50411a7a95d53
  22. // @resource patch_remove_leaderboard_limit https://raw.githubusercontent.com/ragavpr/overrides-wings.io/e7d048bcfdd8b4617071b72d304d052c393aac5e/diff.patch#sha256=1543dfd89d2517af4aace201addb57fdd8d2f11559d8295422040f7fb5f32863
  23. // @license AGPL3
  24. // ==/UserScript==
  25.  
  26. (function () {
  27. // EDITABLE REGION
  28.  
  29. // Comment to disable patch
  30. const patches = [
  31. 'dark_theme',
  32. 'profanity_filter',
  33. // 'always_show_nick_input',
  34. // 'disable_shake',
  35. // 'mark_bots_with_emoji',
  36. // 'mark_bots_with_color',
  37. // 'remove_leaderboard_limit',
  38. ];
  39.  
  40. const settings = {
  41. // Game Version - 10/Oct/2024
  42. wingsio_use_archive: true,
  43. profanity_filter_character: "✲",
  44. debug_profanity_filter_show_filtered: false,
  45. }
  46.  
  47. const profanity_regex_blacklist = [
  48.  
  49. ...(GM_getResourceText('default_profanity_blacklist').split("\n")),
  50. ];
  51. const profanity_regex_whitelist = [
  52.  
  53. ];
  54. // END OF EDITABLE REGION
  55.  
  56. const profanity_filter_extension = `
  57. let profanity_regex_blacklist=\`${profanity_regex_blacklist.toString()}\`.split(',').filter(str => str.length > 0);
  58. let profanity_regex_whitelist=\`${profanity_regex_whitelist.toString()}\`.split(',').filter(str => str.length > 0);
  59. const debug_show_filtered_profanity=${settings.debug_profanity_filter_show_filtered};
  60.  
  61. profanity_regex_blacklist = profanity_regex_blacklist.map(regex_str => new RegExp(regex_str, 'ig'));
  62. profanity_regex_whitelist = profanity_regex_whitelist.map(regex_str => new RegExp(regex_str, 'ig'));
  63. function filter_name(name) {
  64. for (const regex_block of profanity_regex_blacklist) {
  65. name = name.replaceAll(new RegExp(regex_block, 'ig'), match=>{
  66. for(const regex_allow of profanity_regex_whitelist) {
  67. if(match.search(regex_allow) > -1) return match;
  68. }
  69. return '${settings.profanity_filter_character}'.repeat(match.length) + (debug_show_filtered_profanity ? ' ('+match+')' : '');
  70. })
  71. }
  72. return name;
  73. };`;
  74.  
  75. function getPatchedPage() {
  76. const dmp = new diff_match_patch();
  77. dmp.Match_Distance = Infinity;
  78.  
  79. let result, str_html = GM_getResourceText(settings.wingsio_use_archive ? "wingsio_index_html_archive" : "wingsio_index_html");
  80.  
  81. let list_patches = [];
  82. for(const patch of patches) list_patches.push(...(dmp.patch_fromText(GM_getResourceText('patch_'+patch))));
  83.  
  84. [str_html, result] = dmp.patch_apply(list_patches, str_html);
  85. if(patches.includes('profanity_filter')) str_html = str_html.replace('(function(w,x,s){', profanity_filter_extension+'(function(w,x,s){');
  86.  
  87. console.log(result.every(Boolean) ? 'All patches applied successfully' : 'Failed to apply some patches');
  88.  
  89. return str_html;
  90. }
  91.  
  92. var observer = new MutationObserver(mutationRecords => {
  93. mutationRecords.every( record => {
  94. if (record.addedNodes[0]) {
  95. document.write('');
  96. observer.disconnect();
  97. document.write(getPatchedPage());
  98. document.close();
  99. return false
  100. }
  101. return true
  102. })
  103. });
  104.  
  105. observer.observe(document, {
  106. childList: true,
  107. subtree: true
  108. });
  109. })();