wings.io Patches

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

目前為 2024-10-25 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name wings.io Patches
  3. // @namespace http://tampermonkey.net/
  4. // @version 3.4-(25/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 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=35e84754d59ca2256588150fe1a0de3e5bc28eeb8fc6ba2977089addb1f3e322
  17. // @resource feat-profanity-filter https://gw6mc32y.pages.dev/patches/feat-profanity-filter/patch.diff#sha256=69e9f1ef323baeb8aac7568ad9e430469def3319442b1e4f60380bd23dde41e8
  18. // @resource mod-always-show-nickinput https://gw6mc32y.pages.dev/patches/mod-always-show-nickinput/patch.diff#sha256=e9ace3789b4fd92b32878e7bc2ba382ce9465d9cba0bcff5e7bc07d199553983
  19. // @resource mod-disable-shake https://gw6mc32y.pages.dev/patches/mod-disable-shake/patch.diff#sha256=e75676367ef61ec6ca486831335c839c23a086b412a3906f7e5c7057a35772d5
  20. // @resource mod-mark-bots-with-color https://gw6mc32y.pages.dev/patches/mod-mark-bots-with-color/patch.diff#sha256=5815ad548fee2bf94bced7ebef45e00b170bf00826bd6a43cad50411a7a95d53
  21. // @resource mod-mark-bots-with-emoji https://gw6mc32y.pages.dev/patches/mod-mark-bots-with-emoji/patch.diff#sha256=44df21c987f4d68f46a8a0b076ca91a83119ce600d079c54b00f4d925e71c406
  22. // @resource mod-remove-leaderboard-limit https://gw6mc32y.pages.dev/patches/mod-remove-leaderboard-limit/patch.diff#sha256=1543dfd89d2517af4aace201addb57fdd8d2f11559d8295422040f7fb5f32863
  23. // @license AGPL-3.0-or-later
  24. // ==/UserScript==
  25.  
  26. (function () {
  27. // EDITABLE REGION
  28.  
  29. // Comment to disable patch
  30. const patches = [
  31. 'feat-dark-theme',
  32. 'feat-profanity-filter',
  33. // 'mod-always-show-nick-input',
  34. // 'mod-disable-shake',
  35. // 'mod-mark-bots-with-emoji',
  36. // 'mod-mark-bots-with-color',
  37. // 'mod-remove-leaderboard-limit',
  38. ];
  39.  
  40. const settings = {
  41. profanity_filter_character: "✲",
  42. debug_profanity_filter_show_filtered: false,
  43. }
  44.  
  45. const profanity_regex_blacklist = [
  46.  
  47. ...(GM_getResourceText('default_profanity_blacklist').split("\n")),
  48. ];
  49. const profanity_regex_whitelist = [
  50.  
  51. ];
  52. // END OF EDITABLE REGION
  53.  
  54. const profanity_filter_extension = `
  55. let profanity_regex_blacklist=\`${profanity_regex_blacklist.toString()}\`.split(',').filter(str => str.length > 0);
  56. let profanity_regex_whitelist=\`${profanity_regex_whitelist.toString()}\`.split(',').filter(str => str.length > 0);
  57. const debug_show_filtered_profanity=${settings.debug_profanity_filter_show_filtered};
  58.  
  59. profanity_regex_blacklist = profanity_regex_blacklist.map(regex_str => new RegExp(regex_str, 'ig'));
  60. profanity_regex_whitelist = profanity_regex_whitelist.map(regex_str => new RegExp(regex_str, 'ig'));
  61. function filter_name(name) {
  62. for (const regex_block of profanity_regex_blacklist) {
  63. name = name.replaceAll(new RegExp(regex_block, 'ig'), match=>{
  64. for(const regex_allow of profanity_regex_whitelist) {
  65. if(match.search(regex_allow) > -1) return match;
  66. }
  67. return '${settings.profanity_filter_character}'.repeat(match.length) + (debug_show_filtered_profanity ? ' ('+match+')' : '');
  68. })
  69. }
  70. return name;
  71. };`;
  72.  
  73. function getPatchedPage() {
  74. const dmp = new diff_match_patch();
  75. dmp.Match_Distance = Infinity;
  76.  
  77. let result, str_html = GM_getResourceText("wingsio_index_page");
  78.  
  79. let list_patches = [];
  80. for(const patch of patches) list_patches.push(...(dmp.patch_fromText(GM_getResourceText(patch))));
  81.  
  82. [str_html, result] = dmp.patch_apply(list_patches, str_html);
  83. if(patches.includes('feat-profanity-filter')) str_html = str_html.replace('(function(w,x,s){', profanity_filter_extension+'(function(w,x,s){');
  84.  
  85. console.log(result.every(Boolean) ? 'All patches applied successfully' : 'Failed to apply some patches');
  86.  
  87. return str_html;
  88. }
  89.  
  90. var observer = new MutationObserver(mutationRecords => {
  91. mutationRecords.every( record => {
  92. if (record.addedNodes[0]) {
  93. document.write('');
  94. observer.disconnect();
  95. document.write(getPatchedPage());
  96. document.close();
  97. return false
  98. }
  99. return true
  100. })
  101. });
  102.  
  103. observer.observe(document, {
  104. childList: true,
  105. subtree: true
  106. });
  107. })();