Last active
May 10, 2021 02:32
-
-
Save jonpdw/162bd8662778fe87b4511957c19e83a3 to your computer and use it in GitHub Desktop.
RAMM Deeplink.js
This file contains 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 Deeplink (RAMM) | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Automate getting to the right page in RAMM Shell | |
// @author Jonathan De Wet | |
// @match http://localhost:*/rammshell/* | |
// @icon https://www.google.com/s2/favicons?domain=tampermonkey.net | |
// @grant none | |
// ==/UserScript== | |
async function main() { | |
console.log("Deeplink Started") | |
await Sleep(3000) | |
await TryRun("Menu", () => { | |
[...document.querySelectorAll("div")].find(n => n.textContent === "Menu").click() | |
}) | |
// await TryRun("Submitica Control", async () => { | |
// [...document.querySelectorAll("div")].find(n => n.textContent === "Menu").click() | |
// await Sleep(200); | |
// [...document.querySelector("iframe[src*='rammlauncher']").contentWindow.document.querySelectorAll("span")].find(el => el.textContent === 'Submitica Control').click() | |
// }) | |
// await TryRun("RAMM Software Limited", () => { | |
// [...document.querySelector("iframe[src*='submiticacontrol']").contentWindow.document.querySelectorAll("span")].find(el => el.textContent === 'RAMM SOFTWARE LIMITED').click() | |
// }) | |
// await TryRun("Administration", () => { | |
// [...document.querySelector("iframe[src*='submiticacontrol']").contentWindow.document.querySelectorAll("div")].find(el => el.textContent === 'Administration').click() | |
// }) | |
// await TryRun("Wap Template", () => { | |
// [...document.querySelector("iframe[src*='submiticacontrol']").contentWindow.document.querySelectorAll("strong")].find(el => el.textContent === 'WAP Templates').click() | |
// }) | |
// await TryRun("Jono01", () => { | |
// [...document.querySelector("iframe[src*='submiticacontrol']").contentWindow.document.querySelectorAll("span")].find(el => el.textContent === 'Jon01 (Jonathan de)').click() | |
// }) | |
// await TryRun("Color Picker", () => { | |
// document.querySelector("iframe[src*='submiticacontrol']").contentWindow.document.querySelector('h1[data-bind*="chosenBackgroundColor"]').click() | |
// }) | |
console.log("Deeplink Finished") | |
} | |
async function Sleep(ms) { | |
await new Promise(resolve => setTimeout(resolve, ms)); | |
return ms | |
} | |
async function TryRun(name ,func, timeout = 4000) { | |
let timeInFunction = 0 | |
while(true) { | |
timeInFunction += await Sleep(100) | |
if (timeInFunction >= timeout ) { | |
alert("Timout", name) | |
throw new Error("Timeout", name); | |
} | |
try { | |
await func() | |
return | |
} catch (error) { | |
} | |
} | |
} | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment