Ignore dates on posts (I use them to change order of posts.). Sorry for cookies. :(
1 (function () { 2 'use strict'; 3 4 function genString() { 5 'use strict'; 6 var chars = 'QWERTYUIOPP{}ASDFGHJKL:"|ZXCVBNM?qwertyuiopasdfghjkl;zxcvbnm,./`1234567890-=~!@#$%^&*()_+'; 7 for (var cl = chars.length, s = '', i = 50; i > 0; i--) s += chars.charAt(Math.floor(Math.random() * cl)); 8 return s; 9 } 10 11 var rKey = genString(), sKey = genString(); 12 var lock0 = true, lock1 = true; 13 14 function rcv(msg) { 15 'use strict'; 16 if ((msg.source === win) && (msg.data[1] === rKey)) { 17 if ((msg.data[0] === 'agarioskinmod:ready') && lock0) { 18 lock0 = false; 19 URL.revokeObjectURL(bstr); 20 win.postMessage(['agarioskinmod:string', sKey, localStorage.getItem('storeUsersObject')], '*'); 21 } else if ((msg.data[0] === 'agarioskinmod:rstring') && (!lock0) && lock1) { 22 lock1 = false; 23 localStorage.setItem('storeUsersObject', msg.data[2]); 24 window.removeEventListener('message', rcv); 25 location.reload(true); 26 } else if ((msg.data[0] === 'agarioskinmod:exit') && lock1) { 27 lock1 = false; 28 window.removeEventListener('message', rcv); 29 location.reload(true); 30 } 31 32 } 33 } 34 35 window.addEventListener('message', rcv, false); 36 var bstr = URL.createObjectURL(new Blob([`<?xml version="1.0" encoding="UTF-8"?> 37 <!DOCTYPE html 38 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 39 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 40 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 41 <head> 42 <title>agarioskinmod</title> 43 </head> 44 <body> 45 <h3>Replace</h3> 46 <table border="1"> 47 <thead> 48 <tr> 49 <td><b>X</b></td> 50 <td><b>image</b></td> 51 </tr> 52 </thead> 53 <tbody id="tbdy"> 54 <tr> 55 <td colspan="2"><i id="smsg">wait...</i></td> 56 </tr> 57 </tbody> 58 </table> 59 <h3>with <input type="file" id="fle" accept="image/*"/><i>(512x512 image)</i></h3> 60 <input type="button" value="Do it!" id="doit"/> 61 <script type="text/javascript"><![CDATA[ 62 (function () { 63 'use strict'; 64 var lock0 = true; 65 var sKey = '${rKey}', rKey = '${sKey}'; 66 window.onmessage = function (msg) { 67 'use strict'; 68 if ((msg.origin === 'https://agar.io') && (msg.source === window.opener) && (msg.data[0] === 'agarioskinmod:string') && (msg.data[1] === rKey) && lock0) { 69 lock0 = false; 70 var rgarr = msg.data[2].split(/(data:image\\/[a-zA-Z_\\-+\\.]+;base64,[A-Za-z0-9+\\/]+={0,2})/); 71 var tbdy = document.getElementById('tbdy'); 72 var temp2 = rgarr.length; 73 if (temp2 > 2) { 74 for (var temp1 = 1, temp3, temp4, temp5; temp1 < temp2; temp1 += 2) { 75 temp5 = document.createElement('input'); 76 temp5.name = 'simg'; 77 temp5.value = temp1; 78 temp5.type = 'radio'; 79 temp5.checked = false; 80 temp4 = document.createElement('td'); 81 temp4.appendChild(temp5); 82 temp3 = document.createElement('tr'); 83 temp3.appendChild(temp4); 84 temp5 = document.createElement('img'); 85 temp5.alt = 'failed to display image'; 86 temp5.src = rgarr[temp1]; 87 temp4 = document.createElement('td'); 88 temp4.appendChild(temp5); 89 temp3.appendChild(temp4); 90 tbdy.appendChild(temp3); 91 } 92 tbdy.querySelector('input[name=simg]').checked = true; 93 tbdy.removeChild(tbdy.children[0]); 94 var lock1 = true; 95 document.getElementById('doit').onclick = function () { 96 'use strict'; 97 if (lock1) { 98 var fl = document.getElementById('fle').files[0]; 99 if (typeof fl === 'undefined') alert('no file selected'); else { 100 lock1 = false; 101 var fr = new FileReader(); 102 fr.onload = function () { 103 'use strict'; 104 rgarr[tbdy.querySelector('input[name=simg]:checked').value] = fr.result; 105 window.opener.postMessage(['agarioskinmod:rstring', sKey, rgarr.join('')], 'https://agar.io'); 106 alert('Done!'); 107 }; 108 fr.onerror = function () { 109 'use strict'; 110 alert('file read error'); 111 lock1 = true; 112 }; 113 fr.readAsDataURL(fl); 114 } 115 } 116 }; 117 } else document.getElementById("smsg").innerHTML = '<font color="red">no images found</font>'; 118 } 119 }; 120 document.getElementsByTagName('body')[0].onunload = function () { 121 'use strict'; 122 window.opener.postMessage(['agarioskinmod:exit', sKey], 'https://agar.io'); 123 }; 124 setTimeout(function () { 125 'use strict'; 126 window.opener.postMessage(['agarioskinmod:ready', sKey], 'https://agar.io'); 127 }, 100); 128 })(); 129 ]]></script> 130 </body> 131 </html>`], {'type': 'application/xhtml+xml'})); 132 var win = window.open(bstr); 133 })();
No comments:
Post a Comment