Skip to content

Instantly share code, notes, and snippets.

@dcdunkan
Last active May 6, 2024 14:22
Show Gist options
  • Select an option

  • Save dcdunkan/1e57baf2d913b0d93b73fa52edd11df6 to your computer and use it in GitHub Desktop.

Select an option

Save dcdunkan/1e57baf2d913b0d93b73fa52edd11df6 to your computer and use it in GitHub Desktop.

Revisions

  1. dcdunkan revised this gist May 6, 2024. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion etlab-auto-login.userscript.js
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    // @match https://*.etlab.in/*
    // @grant GM_getValue
    // @grant GM_setValue
    // @version 0.3
    // @version 0.4
    // @author Dunkan <https://github.com/dcdunkan>
    // @description 3/12/2024, 2:32:52 AM
    // @run-at document-end
    @@ -55,4 +55,13 @@
    }
    }
    }

    if (window.location.pathname.startsWith("/survey/user/answer/") &&
    Array.from(Array.from(document.getElementsByClassName("answer")).map((x) => Array.from(x.children))).map((x) => x.filter((x) => /Option\[\d+\]/.test(x.name))).flat().length &&
    window.confirm("Do you want to prefill options?")) {
    let i = 0;
    let option = 1;
    do option = Number(window.prompt((i > 0 ? "INVALID input: " : "") + "Enter 1 to 5", "x").trim()), i += 1; while (isNaN(option) || option < 1 || option > 5);
    Array.from(Array.from(document.getElementsByClassName("answer")).map((x) => Array.from(x.children))).map((x) => x.filter((x) => /Option\[\d+\]/.test(x.name))).map((x) => x[option-1].click())
    }
    })();
  2. dcdunkan revised this gist Mar 11, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion etlab-auto-login.userscript.js
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    // @match https://*.etlab.in/*
    // @grant GM_getValue
    // @grant GM_setValue
    // @version 0.2
    // @version 0.3
    // @author Dunkan <https://github.com/dcdunkan>
    // @description 3/12/2024, 2:32:52 AM
    // @run-at document-end
  3. dcdunkan revised this gist Mar 11, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion etlab-auto-login.userscript.js
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    // @match https://*.etlab.in/*
    // @grant GM_getValue
    // @grant GM_setValue
    // @version 0.0
    // @version 0.2
    // @author Dunkan <https://github.com/dcdunkan>
    // @description 3/12/2024, 2:32:52 AM
    // @run-at document-end
  4. dcdunkan revised this gist Mar 11, 2024. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion etlab-auto-login.userscript.js
    Original file line number Diff line number Diff line change
    @@ -4,9 +4,13 @@
    // @match https://*.etlab.in/*
    // @grant GM_getValue
    // @grant GM_setValue
    // @version 0.2
    // @version 0.0
    // @author Dunkan <https://github.com/dcdunkan>
    // @description 3/12/2024, 2:32:52 AM
    // @run-at document-end
    // @homepageURL https://gist.github.com/dcdunkan/1e57baf2d913b0d93b73fa52edd11df6
    // @updateURL https://gist.github.com/dcdunkan/1e57baf2d913b0d93b73fa52edd11df6/raw/etlab-auto-login.userscript.js
    // @downloadURL https://gist.github.com/dcdunkan/1e57baf2d913b0d93b73fa52edd11df6/raw/etlab-auto-login.userscript.js
    // ==/UserScript==

    (function() {
  5. dcdunkan revised this gist Mar 11, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion etlab-auto-login.userscript.js
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    // @match https://*.etlab.in/*
    // @grant GM_getValue
    // @grant GM_setValue
    // @version 0.0
    // @version 0.2
    // @author Dunkan <https://github.com/dcdunkan>
    // @description 3/12/2024, 2:32:52 AM
    // ==/UserScript==
  6. dcdunkan revised this gist Mar 11, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion etlab-auto-login.userscript.js
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@
    // setup credentials
    const hasSetup = GM_getValue("hasSetup", false);
    if (!hasSetup) {
    window.alert("Enter the username and password in the next prompts. Disable the script if decide to stop using it.");
    window.alert("Enter the username and password in the next prompts. Disable the script if you decide to stop using it.");
    let username = "", password = "";
    do username = window.prompt("Username"); while (username.trim() === "");
    do password = window.prompt("Password"); while (password.trim() === "");
  7. dcdunkan revised this gist Mar 11, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion etlab-auto-login.userscript.js
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    // @grant GM_getValue
    // @grant GM_setValue
    // @version 0.0
    // @author Dunkan
    // @author Dunkan <https://github.com/dcdunkan>
    // @description 3/12/2024, 2:32:52 AM
    // ==/UserScript==

  8. dcdunkan revised this gist Mar 11, 2024. 1 changed file with 40 additions and 21 deletions.
    61 changes: 40 additions & 21 deletions etlab-auto-login.userscript.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // ==UserScript==
    // @name etlab auto login
    // @namespace Violentmonkey Scripts
    // @match https://*.etlab.in/user/login*
    // @match https://*.etlab.in/*
    // @grant GM_getValue
    // @grant GM_setValue
    // @version 0.0
    @@ -11,25 +11,44 @@

    (function() {
    console.log("AUTO-LOGIN USERSCRIPT IS RUNNING!");
    // setup credentials
    const hasSetup = GM_getValue("hasSetup", false);
    if (!hasSetup) {
    window.alert("Enter the username and password in the next prompts. Disable the script if decide to stop using it.");
    let username = "", password = "";
    do username = window.prompt("Username"); while (username.trim() === "");
    do password = window.prompt("Password"); while (password.trim() === "");
    GM_setValue("username", username);
    GM_setValue("password", password);
    GM_setValue("askEverytime", window.confirm("Do you want me to ask you everytime before I login you automatically? (Choose wisely!)"));
    GM_setValue("hasSetup", true);
    window.alert("DONE! Clear this script's storage if you wanna reset all this or change credentials");
    }

    // domt autologin
    if (GM_getValue("askEverytime", false) && !window.confirm("Use auto-login?")) return;
    console.log("LOGGING IN...");
    document.getElementById("LoginForm_username").value = GM_getValue("username", "");
    document.getElementById("LoginForm_password").value = GM_getValue("password", "");
    document.getElementById("login-form").submit();
    console.log("LOGGED IN AUTOMATICALLY as", GM_getValue("username"));
    // LOGIN PAGE
    if (window.location.pathname.startsWith("/user/login")) {
    // setup credentials
    const hasSetup = GM_getValue("hasSetup", false);
    if (!hasSetup) {
    window.alert("Enter the username and password in the next prompts. Disable the script if decide to stop using it.");
    let username = "", password = "";
    do username = window.prompt("Username"); while (username.trim() === "");
    do password = window.prompt("Password"); while (password.trim() === "");
    GM_setValue("username", username);
    GM_setValue("password", password);
    GM_setValue("askEverytime", window.confirm("Do you want me to ask you everytime before I login you automatically? (Choose wisely!)"));
    GM_setValue("hasSetup", true);
    window.alert("DONE! Clear this script's storage if you wanna reset all this or change credentials");
    }

    if (localStorage.getItem("triggeredByLogout") === "true")
    if (!window.confirm("You manually logged out last time. Do you want to use auto-login?"))
    return;
    else if (GM_getValue("askEverytime", false))
    if (!window.confirm("Use auto-login?"))
    return;

    localStorage.removeItem("triggeredByLogout");
    console.log("LOGGING IN...");
    document.getElementById("LoginForm_username").value = GM_getValue("username", "");
    document.getElementById("LoginForm_password").value = GM_getValue("password", "");
    document.getElementById("login-form").submit();
    console.log("LOGGED IN AUTOMATICALLY as", GM_getValue("username"));
    } else {
    const logoutLinks = document.getElementsByTagName("a");
    for (const a of logoutLinks) {
    if (a.pathname === "/user/logout") {
    const onClick = 'if(window.confirm("Do you want to log out?")){localStorage.setItem("triggeredByLogout","true");window.location.href="' + a.href + '";}';
    a.outerHTML = "<button onClick='" + onClick + "'>Logout</button>"
    break;
    }
    }
    }
    })();
  9. dcdunkan created this gist Mar 11, 2024.
    35 changes: 35 additions & 0 deletions etlab-auto-login.userscript.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    // ==UserScript==
    // @name etlab auto login
    // @namespace Violentmonkey Scripts
    // @match https://*.etlab.in/user/login*
    // @grant GM_getValue
    // @grant GM_setValue
    // @version 0.0
    // @author Dunkan
    // @description 3/12/2024, 2:32:52 AM
    // ==/UserScript==

    (function() {
    console.log("AUTO-LOGIN USERSCRIPT IS RUNNING!");
    // setup credentials
    const hasSetup = GM_getValue("hasSetup", false);
    if (!hasSetup) {
    window.alert("Enter the username and password in the next prompts. Disable the script if decide to stop using it.");
    let username = "", password = "";
    do username = window.prompt("Username"); while (username.trim() === "");
    do password = window.prompt("Password"); while (password.trim() === "");
    GM_setValue("username", username);
    GM_setValue("password", password);
    GM_setValue("askEverytime", window.confirm("Do you want me to ask you everytime before I login you automatically? (Choose wisely!)"));
    GM_setValue("hasSetup", true);
    window.alert("DONE! Clear this script's storage if you wanna reset all this or change credentials");
    }

    // domt autologin
    if (GM_getValue("askEverytime", false) && !window.confirm("Use auto-login?")) return;
    console.log("LOGGING IN...");
    document.getElementById("LoginForm_username").value = GM_getValue("username", "");
    document.getElementById("LoginForm_password").value = GM_getValue("password", "");
    document.getElementById("login-form").submit();
    console.log("LOGGED IN AUTOMATICALLY as", GM_getValue("username"));
    })();