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