PassEducation-downloader

bypass pass-education paywall

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         PassEducation-downloader
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  bypass pass-education paywall
// @author       Samuel PERRIER
// @match        https://www.pass-education.fr/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=pass-education.fr
// @grant        none
// ==/UserScript==

let links = document.getElementsByClassName("auth-href");
if (links.length != 0)
{
    let urlB = new URL(links[0].getAttribute("href"));
    for (let i = 0; i < links.length; i++)
    {
        let url = new URL(links[i].getAttribute("href"));
        let attachment_id = url.searchParams.get("attachment_id");
        let type_mime = url.searchParams.get("type_mime");
        let new_link = `https://cdn.pass-education.fr/download.php?attachment_id=${attachment_id}&type_mime=${type_mime}`;
        links[i].setAttribute("href", new_link);
    }

    let all_links = document.getElementsByClassName("single-entry-meta pe-subheader");
    let parrent_id = urlB.searchParams.get("parent_id");
    let new_parent_link = `https://cdn.pass-education.fr/download.php?archive_id=${parrent_id}&type_mime=application/zip`;
    for (let j = 0; j < all_links.length; j++)
    {
        all_links[j].innerHTML = `<a href="${new_parent_link}">Télécharger les documents</a>`;
    }
}

function setNewUrl() {
    let buttons = document.getElementsByClassName("mfp-title");
    if (buttons != null && buttons[0].children.length === 2) {
        let url = new URL(buttons[0].children[0].getAttribute("href"));
        let attachment_id = url.searchParams.get("attachment_id");
        let parent_id = url.searchParams.get("parent_id");
        let new_link = `https://cdn.pass-education.fr/download.php?attachment_id=${attachment_id}`;
        let new_parent_link = `https://cdn.pass-education.fr/download.php?archive_id=${parent_id}&type_mime=application/zip`;
        buttons[0].children[0].setAttribute("href", new_link);
        buttons[0].children[1].setAttribute("href", new_parent_link);
    }

    let arrows = document.getElementsByClassName("mfp-arrow");
    for (let i = 0; i < arrows.length; i++)
    {
        arrows[i].addEventListener("click", function() {
            setNewUrl();
        });
    }
}

let fiches = document.getElementsByClassName("row thumb_fiches");
for (let i = 0; i < fiches.length; i++)
{
    fiches[i].addEventListener("click", function() {
        setNewUrl();
    });
}

let login = document.getElementsByClassName("callout warning");
for (let i = 0; i < login.length; i++)
{
    login[i].style.display = "none";
}