Search engine click helper

Auto click test checkbox for search engine course.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Search engine click helper
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Auto click test checkbox for search engine course.
// @match        *://boston.lti.cs.cmu.edu/classes/11-642/HW*
// @grant        none

// ==/UserScript==
const styles = `
.fixedElement {
background-color: transparent;
position:fixed;
top:0;
right:0;
width:40vw;
z-index:100;
height:100px;
}
`;

const styleSheet = document.createElement("style");
styleSheet.type = "text/css";
styleSheet.innerText = styles;
document.head.appendChild(styleSheet);
window.addEventListener('load', function () {
    console.log("loaded");
    const forms = document.querySelectorAll("form");
    for (let f of forms) {
        f.setAttribute('target', '_blank');
    }
    const r = document.querySelectorAll("input[value*='Train']");
    const count = (r.length + 9) / 10;
    const div = document.createElement("div");
    div.classList.add("fixedElement");
    document.body.appendChild(div);
    console.log(count);
    for (let i = 1; i < count; i++) {
        let b = document.createElement("button");
        b.innerText = i;
        b.dataset.i = i;
        div.appendChild(b);
        b.onclick = function () {
            const i = b.dataset.i;
            for (let j = 0; j < r.length; j++) {
                r[j].checked = j >= 10 * (i - 1) && j < 10 * i;
            }
        };
    }
}, false);