Isra.cloud – Restore Original File URL

Displays the original file URL from isra.cloud in the address again, without reloading the page.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Isra.cloud – Restore Original File URL
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Displays the original file URL from isra.cloud in the address again, without reloading the page.
// @author       Yaknar (high-way.me)
// @match        https://isra.cloud/download*
// @run-at       document-start
// @grant        none
// @license      GPL v3
// ==/UserScript==

(function () {
    'use strict';

    function getCookie(name) {
        const match = document.cookie
            .split('; ')
            .find(row => row.startsWith(name + '='));
        if (!match) return null;
        return decodeURIComponent(match.split('=')[1]);
    }

    function updateUrlFromCookie() {
        const code = getCookie('file_code');
        if (!code) return;

        const desiredPath = '/' + code;
        const currentPath = window.location.pathname;

        // Schon umgestellt? Dann nichts tun.
        if (currentPath === desiredPath) return;

        const newUrl = window.location.origin + desiredPath + window.location.search + window.location.hash;

        // URL in der Adressleiste ändern, ohne Reload
        window.history.replaceState(null, '', newUrl);
    }
    updateUrlFromCookie();
})();