Guest User

Untitled

a guest
Apr 18th, 2021
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Granblue Fantasy Texthooker
  3. // @namespace    Granblue.Fantasy.Texthooker
  4. // @version      0.1
  5. // @description  Granblue Fantasy Texthooker
  6. // @author       Anonymous
  7. // @match        *://game.granbluefantasy.jp/*
  8. // @grant        none
  9. //
  10. // IMPORTANT - IMPORTANT - IMPORTANT - IMPORTANT - IMPORTANT !!!!!!!
  11. // Go in settings > quests and toggle "display text instantly" on
  12. // see https://imgur.com/a/PlmsowT
  13. // IMPORTANT - IMPORTANT - IMPORTANT - IMPORTANT - IMPORTANT !!!!!!
  14. //
  15. // ==/UserScript==
  16.  
  17. var adviceTxt = "";
  18. var messageTxt = "";
  19. var explainTxt = "";
  20. var popupTxt = "";
  21. var oldAdviceTxt = "";
  22. var oldMessageTxt = "";
  23. var oldExplainTxt = "";
  24. var oldPopupTxt = "";
  25. /*
  26. function addGlobalStyle(css) {
  27.     var head, style;
  28.     head = document.getElementsByTagName('head')[0];
  29.     if (!head) { return; }
  30.     style = document.createElement('style');
  31.     style.type = 'text/css';
  32.     style.innerHTML = css;
  33.     head.appendChild(style);
  34. }
  35.  
  36. addGlobalStyle('* { -webkit-user-select: all !important; }');
  37. */
  38. void function mymain() {
  39.     const copyToClipboard = str => {
  40.         const myel = document.createElement('textarea');
  41.         myel.value = str;
  42.         myel.setAttribute('readonly', '');
  43.         myel.style.position = 'absolute';
  44.         myel.style.left = '-9999px';
  45.         document.body.appendChild(myel);
  46.         myel.select();
  47.         document.execCommand('copy');
  48.         document.body.removeChild(myel);
  49.     };
  50.  
  51.     function toTxt(prt) {
  52.         if (prt != null && prt.length >= 1) {
  53.             return prt[0].outerHTML.replace(/<[^>]*>/g, '').replace(/\n/g,'');
  54.         }
  55.        return "";
  56.     }
  57.  
  58.     var prtMessage = document.getElementsByClassName('prt-message-area');
  59.     var prtAdvice = document.getElementsByClassName('prt-advice');
  60.     var prtExplain = document.getElementsByClassName('prt-explain');
  61.     var prtPopup = document.getElementsByClassName('prt-popup-body');
  62.  
  63.     messageTxt = toTxt(prtMessage);
  64.     if (messageTxt != "") {
  65.         if (messageTxt != oldMessageTxt) {
  66.             oldMessageTxt = messageTxt;
  67.             console.log(messageTxt);
  68.             copyToClipboard(messageTxt);
  69.         }
  70.     }
  71.  
  72.     adviceTxt = toTxt(prtAdvice);
  73.     if (adviceTxt != "") {
  74.         if (adviceTxt != oldAdviceTxt) {
  75.             oldAdviceTxt = adviceTxt;
  76.             console.log(adviceTxt);
  77.             copyToClipboard(adviceTxt);
  78.         }
  79.     }
  80.  
  81.     explainTxt = toTxt(prtExplain);
  82.     if (explainTxt != "") {
  83.         if (explainTxt != oldExplainTxt) {
  84.             oldExplainTxt = explainTxt;
  85.             console.log(explainTxt);
  86.             copyToClipboard(explainTxt);
  87.         }
  88.     }
  89.  
  90.     popupTxt = toTxt(prtPopup);
  91.     if (popupTxt != "") {
  92.         if (popupTxt != oldPopupTxt) {
  93.             oldPopupTxt = popupTxt;
  94.             console.log(popupTxt);
  95.             copyToClipboard(popupTxt);
  96.         }
  97.     }
  98.  
  99.     setTimeout(mymain, 700);
  100. }();
Advertisement
Add Comment
Please, Sign In to add comment