Execute Script

Runs booking functions at given urls

اعتبارا من 18-05-2022. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         Execute Script
// @namespace    http://tampermonkey.net/
// @version      0.5
// @license      MIT
// @description  Runs booking functions at given urls
// @author       Me
// @match        https://topup.chch.ox.ac.uk/BlockBook.aspx*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=ox.ac.uk
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';

    // Create button elements:
    var button1 = document.createElement("button");
    var button2 = document.createElement("button");
    button1.innerText = "Book Formal Hall";
    button2.innerText = "Book Informal Hall";

    // Append to body:
    document.body.appendChild(button1);
    document.body.appendChild(button2);

    button1.onclick = redirectFormal;
    button2.onclick = redirectInformal;

    if (window.location.href == "https://topup.chch.ox.ac.uk/BlockBook.aspx?autobook=formal") {
        bookFormal()
    }

    else if (window.location.href == "https://topup.chch.ox.ac.uk/BlockBook.aspx?autobook=informal") {
        bookInformal()
    }


    function bookFormal() {

        document.getElementById("lstSession").value = "D"

        document.getElementById("lstSitting").value = 2

        document.getElementById("ContentPlaceHolder1_chkSun").checked = true
        document.getElementById("ContentPlaceHolder1_chkMon").checked = true
        document.getElementById("ContentPlaceHolder1_ChkTue").checked = true
        document.getElementById("ContentPlaceHolder1_chkWed").checked = true
        document.getElementById("ContentPlaceHolder1_chkThurs").checked = true
        document.getElementById("ContentPlaceHolder1_chkFri").checked = true
        document.getElementById("ContentPlaceHolder1_chkSat").checked = true

        //document.getElementById("ContentPlaceHolder1_lstDietary_2").checked = true

        //document.getElementById("ContentPlaceHolder1_txtDietaryInfo").innerHTML = "I don't care if it's free, take the gluten out the damn bread"

        //document.getElementById("ContentPlaceHolder1_btnBlockBook").click()
        clickButton()

    }

    function bookInformal() {

        document.getElementById("lstSession").value = "D"

        document.getElementById("lstSitting").value = 1

        document.getElementById("ContentPlaceHolder1_chkSun").checked = true
        document.getElementById("ContentPlaceHolder1_chkMon").checked = true
        document.getElementById("ContentPlaceHolder1_ChkTue").checked = true
        document.getElementById("ContentPlaceHolder1_chkWed").checked = true
        document.getElementById("ContentPlaceHolder1_chkThurs").checked = true
        document.getElementById("ContentPlaceHolder1_chkFri").checked = true
        document.getElementById("ContentPlaceHolder1_chkSat").checked = true

        //document.getElementById("ContentPlaceHolder1_lstDietary_2").checked = true

        //document.getElementById("ContentPlaceHolder1_txtDietaryInfo").innerHTML = "I don't care if it's free, take the gluten out the damn bread"

        //document.getElementById("ContentPlaceHolder1_btnBlockBook").click()
        clickButton()

    }

    function clickButton() {

        document.getElementById("ContentPlaceHolder1_btnBlockBook").click()
    }

    function redirectInformal() {

        window.location.href = "https://topup.chch.ox.ac.uk/BlockBook.aspx?autobook=informal"

    }

    function redirectFormal() {

        window.location.href = "https://topup.chch.ox.ac.uk/BlockBook.aspx?autobook=formal"

    }

})();