pyAnywhere clickable file paths

subj

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         pyAnywhere clickable file paths
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  subj
// @author       Alex R
// @license      none
// @match        https://*.pythonanywhere.com/user/*/tasks_tab/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=pythonanywhere.com
// @grant        none
// ==/UserScript==
console.log("py")
let allTasks;
const suffix = "?edit";
const fileNameRE = /python3\.10(.*\.py)/;
const origin = "https://eu.pythonanywhere.com/user/alexdiscordbot/files/";
const notFound = setInterval(()=>{
    allTasks = Array.from(document.querySelectorAll(".wide-column.scheduled_tasks_command"));
    if (allTasks.length !== 0){
        clearInterval(notFound);
        allTasks.push(document.querySelector(".always_on_task_command"));
        main();
    }
}, 100);
function main(){
    allTasks.forEach(task=>{
        let filePath = task.textContent.match(fileNameRE)[1];
        console.log(filePath, filePath.startsWith(" mysite"));
        let newFilePath = filePath;
        if (filePath.startsWith(" mysite")) newFilePath = "/home/alexdiscordbot/" + filePath.trim();
        console.log("newFilePath", newFilePath)
        task.textContent = task.textContent.replace(filePath, "");
        let a = document.createElement("a");
        a.innerHTML = newFilePath;
        a.href = origin + newFilePath.trim() + suffix;
        task.appendChild(a);
    });
}
const loadedInterval = setInterval(()=>{
    const timeSpan = document.querySelector("#id_server_time");
    if (!timeSpan) return;
    const timeArr = timeSpan.textContent.split(":");
    document.querySelector("#id_scheduled_tasks_table > div > form > input:nth-child(2)").value = timeArr[0];
    document.querySelector("#id_scheduled_tasks_table > div > form > input:nth-child(3)").value = parseInt(timeArr[1]) + 1;
    clearInterval(loadedInterval);
}, 100);