Word Helper for Word guessing game

A script that showing a list of possible words for the current target word and allowing the user to easily input them into the chat.

Skript installieren?
Vom Ersteller vorgeschlagenes Skript

Ihnen könnte auch Bypass Stencil Sticker's Size Limit gefallen.

Skript installieren
  1. // ==UserScript==
  2. // @name Word Helper for Word guessing game
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description A script that showing a list of possible words for the current target word and allowing the user to easily input them into the chat.
  6. // @match https://*.drawaria.online/*
  7. // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js
  8. // @author Vholran
  9. // @icon https://www.google.com/s2/favicons?domain=drawaria.online
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (($, undefined) => {
  14. $(() => {
  15. let wordCheatPanel = () => {
  16. const $sendButton = $('#chatattop-sendbutton');
  17. const $inputChat = $('#chatbox_textinput');
  18. const $targetWord = $('#targetword_tip');
  19. const $rightBar = $('#rightbar');
  20. const $hintsBox = $('<span id="hintsBox">');
  21. let lang = $('#langselector').val();
  22. let wordList;
  23.  
  24. $('<div id="hintsPanel" style="display:none; background: #eeeeee; overflow-wrap: anywhere; border: 4px solid #eeeeee; border-radius: 2px; overflow-y: scroll; height: 100%; width:100%; margin: 8px 0 0 0; color: #3675ce;">')
  25. .insertAfter($rightBar.children().eq(3))
  26. .append($hintsBox);
  27.  
  28. $("body").on('click', '.hintClick', event => {
  29. $inputChat.val(event.target.innerHTML);
  30. $sendButton.click();
  31. });
  32. const assist = () => {
  33. if (!wordList) {
  34. return;
  35. }
  36.  
  37. $hintsBox.empty();
  38. let wordRegex = $targetWord.text().replace(/_/g, '[^ \\-"]');
  39. wordRegex = `"${wordRegex}"`;
  40. wordRegex = new RegExp(wordRegex, 'g');
  41. let hints = wordList.match(wordRegex);
  42.  
  43. if (!hints) {
  44. $hintsBox.append('<span style="color:red; font-weight:bold">Sorry, no word found!</span>');
  45. } else {
  46. $hintsBox.append('<span style="color:green; font-weight:bold">Click any word to send it: </span><br>');
  47. hints = hints.map(hint => hint.slice(1, -1));
  48. let newHints = hints.filter(hint => !$inputChat.val() || hint.toLowerCase().search($inputChat.val().toLowerCase()) === -1);
  49. hints = hints.filter(hint => !newHints.includes(hint));
  50. let html = [...hints.map((hint, i) => `<a style="color:#007CFF; background:#C6FE71; user-select:none" href="javascript:void(0);" class="hintClick">${hint}</a>`),
  51. ...newHints.map((hint, i) => `<a style="background:none; user-select:none" href="javascript:void(0);" class="hintClick">${hint}</a>`)].join(', ');
  52. $hintsBox.append(html);
  53. }
  54. };
  55.  
  56. $inputChat.on('input', assist);
  57. const targetWord = $targetWord[0];
  58. const hintsPanel = $('#hintsPanel');
  59.  
  60. const initialize = async () => {
  61. try{
  62. wordList = await fetch(`https://api.npoint.io/0fc9dd19c4867f584b74/${lang}`).then(response => response.text());
  63. }catch(e){
  64. await new Promise((resolve) => setTimeout(resolve, 300));
  65. return initialize();
  66. }
  67. wordList = wordList.slice(1, -1);
  68. };
  69. initialize();
  70.  
  71. const wordTipObserver = new MutationObserver((mutations) => {
  72. mutations.forEach((mutation) => {
  73. if (targetWord.style.display === 'none') {
  74. hintsPanel.hide();
  75. } else {
  76. hintsPanel.show();
  77. assist();
  78. }
  79. });
  80. });
  81. wordTipObserver.observe(targetWord, { attributes: true, attributeFilter: ['style'] });
  82.  
  83. const refreshWordObserver = new MutationObserver(function(mutations) {
  84. if (mutations[0].target.disabled) {
  85. $('#wordchooser-refreshlist').prop("disabled",false);
  86. }
  87. });
  88. refreshWordObserver.observe($('#wordchooser-refreshlist')[0], {attributes: true});
  89. };
  90.  
  91. const roomKeywords = /\слов|Palabras|Word/;
  92. $("#infotext").on("DOMSubtreeModified", e => {
  93. if (roomKeywords.test(e.target.textContent)) {
  94. wordCheatPanel();
  95. $(e.target).off("DOMSubtreeModified");
  96. }
  97. });
  98. });
  99. })(window.jQuery.noConflict(true));