gimmickCellar

hashbrown THREE

Jun 30th, 2026 (edited)
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. // ==UserScript==
  2. // @name HashBrown 3
  3. // @author gimmickCellar
  4. // @description hashing for owot and any secure nwot
  5. // @match *://*/*
  6. // ==/UserScript==
  7.  
  8. //i am so sorry for the state of this codebase
  9. var privateKey; //prevent error
  10. var publicKeyBase64;
  11. window.hashcache = []; //also prevent error
  12.  
  13. async function startCryptoApi() { //mostly lifted from hb2, this is really the only segment that is, because this is kinda the only way to do it
  14. var storedKeys = localStorage.getItem('hb3'); //ok so this is the local storage. it stores, locally. wow.
  15. if (storedKeys) {
  16. var keys = JSON.parse(storedKeys); //Jason
  17. privateKey = await crypto.subtle.importKey("jwk", keys.priv||keys.jwkpr, {name:"ECDSA",namedCurve:"P-256"},true,["sign"]); //just sign, please!
  18. publicKeyBase64 = keys.pubBase64;
  19. } else {
  20. var pair = await crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},true,["sign","verify"]); //sign AND verify, please
  21. privateKey = pair.privateKey;
  22. var pub = pair.publicKey;
  23. var jwkpr = await crypto.subtle.exportKey("jwk",privateKey);
  24. var jwkpu = await crypto.subtle.exportKey("jwk",pub);
  25. var Pub = await crypto.subtle.exportKey("raw",pub);
  26. publicKeyBase64 = btoa(String.fromCharCode(...new Uint8Array(Pub)));
  27. localStorage.setItem('hb3',JSON.stringify({jwkpr,jwkpu,pubBase64:publicKeyBase64})); //local storage
  28. }
  29. }
  30.  
  31. w.tileToChar=(tileX,tileY,charX,charY)=>{ //helper, available to other scripts but why would you
  32. var x = tileX * 16 + charX;
  33. var y = tileY * 8 + charY;
  34. return {x:x,y:y}; //x is x and y is y!
  35. };
  36.  
  37. w.TemperTantrum=()=>{return new Error("VIGUEGYU8ZVGJHVTJYZVGYJA YOU LIED YOU LIED YOU LIED")}; // literally just uq
  38.  
  39. async function url(item){
  40. if(!item)throw w.TemperTantrum(); // average owot user
  41. var x=item[0];var y=item[1];var chara=item[2];var d=item[3];var u=item[4];var wd=item[5]; // chara and wd gaster in the same line
  42. // ok but seriously wd is world, chara is character, d is deco and u is username
  43. var msg=`${wd},${x},${y},${chara},${d},${u}`;
  44. var enc=new TextEncoder().encode(msg);
  45. var sigBuf=await crypto.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},privateKey,enc);
  46. var sigArr=new Uint8Array(sigBuf);
  47. var sigB64=btoa(String.fromCharCode(...sigArr));
  48. var verifier="https://gimmickcellar.nekoweb.org/verifyhash2.html"; //change this line to use your gerifier
  49. var ew=encodeURIComponent(wd);
  50. var eu=encodeURIComponent(u);
  51. var es=encodeURIComponent(sigB64).replace(/\+/g,'%2B');
  52. var ep=encodeURIComponent(publicKeyBase64).replace(/\+/g,'%2B');
  53. return `${verifier}?w=${ew}&x=${x}&y=${y}&c=${chara}&d=${d}&u=${eu}&sig=${es}&pub=${ep}`;
  54. }
  55.  
  56. (()=>{
  57. w.on("write",e=>{
  58. if(e.char==="\x08"||e.char===" "||e.char==="\xa0")return;
  59. var u=state.userModel.username; //you.
  60. var wd=state.worldModel.name || "Main"; //wd gasters.,,.,,,, (seriously, this is just compat with slopbrown 2 also for world checking)
  61. var id=nextObjId-1; //write id
  62. var coords=w.tileToChar(e.tileX,e.tileY,e.charX,e.charY);
  63. var x=coords.x;
  64. var y=coords.y;
  65. var tx=e.tileX;
  66. var ty=e.tileY;
  67. var cx=e.charX;
  68. var cy=e.charY; //just for safe keeping
  69. var chara=e.char.codePointAt(0);
  70. var d=0; //todo: proper text deco support, rn is 0 to have compat with the vibecoded slop hb2
  71. window.hashcache[id]=[x,y,chara,d,u,wd,tx,ty,cx,cy];
  72. });
  73. w.on("writeResponse",e=>{
  74. if((!e.accepted)||window["hashn'tbrown"])return; // hash brown or hashn't brown?
  75. e.accepted.forEach(async id=>{
  76. var a=window.hashcache[id]; //hashcache is cache for hashing
  77. if(!a)return;
  78. var linkVal=await url(a); //url makes a url
  79. network.link({tileX:a[6],tileY:a[7],charX:a[8],charY:a[9]},"url",{url:linkVal}); //a is a weirdly arranged array if you didnt see the above
  80. delete window.hashcache[id];
  81. });
  82. });
  83. menu.addCheckboxOption("Disable HashBrown 3",()=>{window["hashn'tbrown"]=true},()=>{window["hashn'tbrown"]=false}) //todo: make this save
  84. startCryptoApi(); //starts crypto api
  85. })()
Add Comment
Please, Sign In to add comment