// ==UserScript== // @name Amazon Autologin // @namespace Amazon Autologin // @description A userscript that automatically fills in the password for your Amazon login attempts and also enters the correct 2FA code. Additionally it skips the reminder that asks you to add a phone number for SMS verification // @include *amazon.de/*signin* // @include *amazon.de/*mfa* // @include *amazon.de/*accountfixup* // @include *amazon.com/*signin* // @include *amazon.com/*mfa* // @include *amazon.com/*accountfixup* // @version 3 // @author Bellianik // @grant GM_setValue // @grant GM_getValue // @run-at document-end // @downloadURL https://update.greasyfork.icu/scripts/428145/Amazon%20Autologin.user.js // @updateURL https://update.greasyfork.icu/scripts/428145/Amazon%20Autologin.meta.js // ==/UserScript== //I would be very happy for any feedback you can leave on greasyfork or openuserjs. It is the reason I wanted to share this neat script in the first place :). Enjoy var credentials = [ "myaccount@gmail.com", "my_password", "my_2fa_secret", "mysecondaccount@hotmail.com", "my_password", "my_2fa_secret", "mythirdaccount@yahoo.com", "my_password", "none. if you do not use 2FA you can just remove this entry, leave it empty or add whatever you want", ]; // from https://github.com/Caligatio/jsSHA // including sha1 makes this a single, downloadable, self-contained html document! /* A JavaScript implementation of the SHA family of hashes, as defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding HMAC implementation as defined in FIPS PUB 198a Copyright 2008-2018 Brian Turek, 1998-2009 Paul Johnston & Contributors Distributed under the BSD License See http://caligatio.github.com/jsSHA/ for more information */ 'use strict';(function(G){function r(d,b,c){var h=0,a=[],f=0,g,m,k,e,l,p,q,t,w=!1,n=[],u=[],v,r=!1;c=c||{};g=c.encoding||"UTF8";v=c.numRounds||1;if(v!==parseInt(v,10)||1>v)throw Error("numRounds must a integer >= 1");if("SHA-1"===d)l=512,p=z,q=H,e=160,t=function(a){return a.slice()};else throw Error("Chosen SHA variant is not supported");k=A(b,g);m=x(d);this.setHMACKey=function(a,f,b){var c;if(!0===w)throw Error("HMAC key already set");if(!0===r)throw Error("Cannot set HMAC key after calling update"); g=(b||{}).encoding||"UTF8";f=A(f,g)(a);a=f.binLen;f=f.value;c=l>>>3;b=c/4-1;if(ca/8){for(;f.length<=b;)f.push(0);f[b]&=4294967040}for(a=0;a<=b;a+=1)n[a]=f[a]^909522486,u[a]=f[a]^1549556828;m=p(n,m);h=l;w=!0};this.update=function(b){var e,g,c,d=0,q=l>>>5;e=k(b,a,f);b=e.binLen;g=e.value;e=b>>>5;for(c=0;c>>5);f=b%l;r=!0};this.getHash=function(b,g){var c,k,l,p;if(!0=== w)throw Error("Cannot call getHash after setting HMAC key");l=B(g);switch(b){case "HEX":c=function(a){return C(a,e,l)};break;case "B64":c=function(a){return D(a,e,l)};break;case "BYTES":c=function(a){return E(a,e)};break;case "ARRAYBUFFER":try{k=new ArrayBuffer(0)}catch(I){throw Error("ARRAYBUFFER not supported by this environment");}c=function(a){return F(a,e)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER");}p=q(a.slice(),f,h,t(m),e);for(k=1;k>>2]>>>8*(3+a%4*-1),h+="0123456789abcdef".charAt(f>>>4&15)+"0123456789abcdef".charAt(f&15);return c.outputUpper?h.toUpperCase():h}function D(d,b,c){var h="",a=b/8,f,g,m;for(f=0;f>>2]:0,m=f+2>>2]:0,m=(d[f>>>2]>>>8*(3+f%4*-1)&255)<<16|(g>>>8*(3+(f+1)%4*-1)&255)<<8|m>>>8*(3+(f+2)%4*-1)&255,g=0;4>g;g+=1)8*f+6*g<=b?h+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(m>>> 6*(3-g)&63):h+=c.b64Pad;return h}function E(d,b){var c="",h=b/8,a,f;for(a=0;a>>2]>>>8*(3+a%4*-1)&255,c+=String.fromCharCode(f);return c}function F(d,b){var c=b/8,h,a=new ArrayBuffer(c),f;f=new Uint8Array(a);for(h=0;h>>2]>>>8*(3+h%4*-1)&255;return a}function B(d){var b={outputUpper:!1,b64Pad:"=",shakeLen:-1};d=d||{};b.outputUpper=d.outputUpper||!1;!0===d.hasOwnProperty("b64Pad")&&(b.b64Pad=d.b64Pad);if("boolean"!==typeof b.outputUpper)throw Error("Invalid outputUpper formatting option"); if("string"!==typeof b.b64Pad)throw Error("Invalid b64Pad formatting option");return b}function A(d,b){var c;switch(b){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(d){case "HEX":c=function(b,a,f){var g=b.length,c,d,e,l,p;if(0!==g%2)throw Error("String of HEX type must be in byte increments");a=a||[0];f=f||0;p=f>>>3;for(c=0;c>>1)+p;for(e=l>>>2;a.length<=e;)a.push(0);a[e]|=d<<8*(3+l%4*-1)}return{value:a,binLen:4*g+f}};break;case "TEXT":c=function(c,a,f){var g,d,k=0,e,l,p,q,t,n;a=a||[0];f=f||0;p=f>>>3;if("UTF8"===b)for(n=3,e=0;eg?d.push(g):2048>g?(d.push(192|g>>>6),d.push(128|g&63)):55296>g||57344<=g?d.push(224|g>>>12,128|g>>>6&63,128|g&63):(e+=1,g=65536+((g&1023)<<10|c.charCodeAt(e)&1023),d.push(240|g>>>18,128|g>>>12&63,128|g>>>6&63,128|g&63)),l=0;l>>2;a.length<=q;)a.push(0);a[q]|=d[l]<<8*(n+t%4*-1);k+=1}else if("UTF16BE"===b||"UTF16LE"===b)for(n=2,d="UTF16LE"===b&&!0||"UTF16LE"!==b&&!1,e=0;e>>8);t=k+p;for(q=t>>>2;a.length<=q;)a.push(0);a[q]|=g<<8*(n+t%4*-1);k+=2}return{value:a,binLen:8*k+f}};break;case "B64":c=function(b,a,f){var c=0,d,k,e,l,p,q,n;if(-1===b.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");k=b.indexOf("=");b=b.replace(/\=/g, "");if(-1!==k&&k= str.length) { str = Array(len + 1 - str.length).join(pad) + str; } return str; }; function updateOtp( secret ) { var epoch = Math.round(new Date().getTime() / 1000.0); var time = leftpad(dec2hex(Math.floor(epoch / 30)), 16, '0'); var shaObj = new jsSHA("SHA-1", "HEX"); shaObj.setHMACKey( base32tohex( secret ), "HEX"); shaObj.update(time); var hmac = shaObj.getHMAC("HEX"); if (hmac == 'KEY MUST BE IN BYTE INCREMENTS') { } else { var offset = hex2dec(hmac.substring(hmac.length - 1)); } var otp = (hex2dec(hmac.substr(offset * 2, 8)) & hex2dec('7fffffff')) + ''; otp = (otp).substr(otp.length - 6, 6); return otp; }; function isValidSecret( s ) { if ( !/^[a-zA-Z2-7]+$/.test( s ) ) { // only allow base32 return false; } var epoch = Math.round(new Date().getTime() / 1000.0); var time = leftpad(dec2hex(Math.floor(epoch / 30)), 16, '0'); var shaObj = new jsSHA("SHA-1", "HEX"); try { shaObj.setHMACKey( base32tohex(s), "HEX"); shaObj.update(time); var hmac = shaObj.getHMAC("HEX"); return (hmac != "KEY MUST BE IN BYTE INCREMENTS"); } catch(err) { return false; // e.g. HEX string 's' not actually in byte increments, try again.. } }; function getValidSecret( secret ) { if ( isValidSecret( secret ) ) { return secret.toUpperCase(); } return undefined; }; function getOTP( s ) { var secret = getValidSecret(s); if ( secret ) { return updateOtp( secret ); } else { return undefined } }; (function() { 'use strict'; var errorElements = document.querySelectorAll('.a-alert-error'); //error on page, prevent endless retries to avoid ban for(var i = 0; i < errorElements.length; i++) { if (errorElements[i].id !== 'passkey-error-alert') { console.log("Error on page detected! Aborting"); return; } } if(document.getElementById("auth-mfa-remember-device")) { //check if on OTP/2step code entry page document.getElementById("auth-mfa-remember-device").checked = 1 var email = GM_getValue("lastEmail", "none"); var index = credentials.indexOf(email); if(index == -1) { console.log("Unknown email address! Aborting"); return; } var otp = getOTP(credentials[index+2]); document.getElementById("auth-mfa-otpcode").value = otp; if(document.getElementById("image-captcha-section") || document.getElementById("auth-captcha-image")) { console.log("Captcha detected! Aborting"); return; } else { document.getElementById("auth-signin-button").click(); } return; } if(document.querySelector('input[aria-labelledby$="ap-account-fixup-phone-pin-code-button-announce"]')) { //skip the add phone for sms verification reminder document.getElementById("ap-account-fixup-phone-skip-link").click(); return; } if (document.getElementById("signInSubmit")){ //check if login page var email = document.getElementById("ap-credential-autofill-hint").value; //document.querySelector(".a-row.a-size-base.a-color-tertiary.auth-text-truncate").innerText; GM_setValue("lastEmail", email); var index = credentials.indexOf(email); if(index == -1) { console.log("Unknown email address! Aborting"); return; } document.getElementById("ap_password").value = credentials[index+1]; // document.querySelector('input[name$="rememberMe"]').checked = 1 // as of around December 2025 this field does not exist anymore I think and causes script to cease working if(document.getElementById("image-captcha-section") || document.getElementById("auth-captcha-image")) { console.log("Captcha detected! Aborting"); return; } else { document.getElementById("signInSubmit").click(); } } })();