Created
November 27, 2023 06:37
-
-
Save Syakhisk/84a810a8180747491d915f088c964e37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Google SSO Account Picker | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://accounts.google.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=accounts.google.com | |
// @grant none | |
// @run-at document-end | |
// @noframes | |
// ==/UserScript== | |
function main() { | |
const myEmail = "[email protected]"; | |
const patterns = [ | |
/https?:\/\/wd3\.myworkday\.com\/gojek/, | |
/https?:\/\/accounts\.google\.com\/o\/saml2\/idp/, | |
]; | |
const elements = Array.from(document.querySelectorAll(`[data-authuser]`)); | |
const el = elements.find((e) => e.dataset.identifier == myEmail); | |
if (!el) { | |
console.log("TamperMonkey: Account not found"); | |
return; | |
} | |
const url = new URL(window.location.href); | |
const redirectUri = url.searchParams.get("redirect_uri"); | |
const continueParams = url.searchParams.get("continue"); | |
for (let p of patterns) { | |
if (!p.test(redirectUri) && !p.test(continueParams)) continue; | |
console.log("TamperMonkey: Matched: " + redirectUri); | |
const isBusy = document.querySelector( | |
'div[role="presentation"][tabindex="-1"]', | |
); | |
const hasBackButton = document.querySelector('div[role="button"]#next'); | |
if (isBusy) { | |
console.log("Page is busy..."); | |
} | |
// Close page if there was "unknown error" | |
if (hasBackButton) { | |
window.close(); | |
} | |
// Try clicking until page gets busy | |
if (!isBusy) { | |
console.log("Clicking..."); | |
console.log(el); | |
el.click(); | |
} | |
} | |
} | |
(async function () { | |
"use strict"; | |
console.log("TamperMonkey: Running..."); | |
await new Promise((resolve) => setTimeout(resolve, 500)); | |
setInterval(main, 500); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment