Keyboard Display Script

shows keyboard inputs on screen

2019/06/13のページです。最新版はこちら

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
  1. // ==UserScript==
  2. // @name Keyboard Display Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description shows keyboard inputs on screen
  6. // @author Oki
  7. // @match https://*.jstris.jezevec10.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. /**************************
  12. Keyboard Display Script
  13. **************************/
  14.  
  15. (function() {
  16. window.addEventListener('load', function(){
  17.  
  18. if(typeof Game != "undefined"){
  19. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  20.  
  21. document['addEventListener']('keydown', press);
  22. document['addEventListener']('keyup', press);
  23.  
  24. function press(e) {
  25. if(~Game['set2ings'].indexOf(e.keyCode)){
  26. var corresponding = [6,8,1,2,3,5,4,0][Game['set2ings'].indexOf(e.keyCode)]
  27. document.getElementsByClassName("kbkey")[corresponding].style.backgroundColor = ["lightgoldenrodyellow",""][+(e.type=="keyup")]
  28. }
  29. }
  30.  
  31. var kbhold=document.createElement("div");
  32. kbhold.id="keyboardHolder";
  33. kbhold.style.position="absolute"
  34. kbhold.style.left = (myCanvas.getBoundingClientRect().left - 300) + "px";
  35. kbhold.style.top = (myCanvas.getBoundingClientRect().top + 100) + "px";
  36. document.body.appendChild(kbhold);
  37.  
  38. var f='<R>M{text-align:center;position: absolute;font-size:15px`{]-Q:QIspacing:0;Nred`td|th|Uwp8o_000000;]:inherit`UT_34ff34`Ujy2k_f8a102`UO_f8ff00;}</RYbo"Yps"KPJV"Ptr^Tq180~TqSD~TqHDZ[CCWZXtr^OqHL~OqCWZ[&lt;[v[&gt;X/JK>~</td^|{padding:10px 5pxIR:solidIwidth:2px`q kbkey">`;}M.tg _{]-N#^PtdV-]border[~jy2kqZ~wp8o">YPdiv id="kX</tdP/trPV class="tgU.tg-Ttc3eRstyleQcollapseP><Op39mNcolor:M#kbo KP/divJtableI;]-';var g=0;var i=0;for(i in g='IJKMNOPQRTUVXYZ[]^_`q|~')var e=f.split(g[i]),f=e.join(e.pop())
  39. keyboardHolder.innerHTML = f
  40.  
  41. var set2ings = Game['prototype']['readyGo'].toString()
  42. set2ings = "Game['set2ings']=this.Settings.controls;" + trim(set2ings)
  43. Game['prototype']['readyGo'] = new Function(set2ings);
  44.  
  45. var updateTextBarFunc = Game['prototype']['updateTextBar'].toString()
  46. updateTextBarFunc = trim(updateTextBarFunc) + ";kps.innerHTML='KPS: '+(this.getKPP()*this.placedBlocks/this.clock).toFixed(2)"
  47. Game['prototype']['updateTextBar'] = new Function(updateTextBarFunc);
  48.  
  49. }
  50.  
  51. });
  52. })();