Unblur Text for studeersnel.nl

Unblur text

目前為 2023-12-15 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Unblur Text for studeersnel.nl
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Unblur text
// @author       cvolt
// @license      GPL3
// @match        https://www.studeersnel.nl/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to remove an element by XPath
    function removeElementByXPath(xpath) {
        const result = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
        const element = result.singleNodeValue;
        if (element) {
            element.style.display = 'none';
        }
    }

    // New function to remove elements by a dynamic pattern
    function removeElementsByDynamicPattern() {
        const characters = ['', ...'abcdefghijklmnopqrstuvwxyz'.split('')];
        characters.forEach(char => {
            for (let i = 1; i <= 20; i++) {
                let dynamicXPath = `//*[@id="pf${i}${char}"]/div[2]`;
                removeElementByXPath(dynamicXPath);
            }
        });
    }

    // Function to inject custom style for unblurring text and enabling text selection
    function injectStyle() {
        const style = document.createElement('style');
        style.type = 'text/css';
        style.innerHTML = `
            .page-content { filter: none !important; }
            * { user-select: text !important; }
        `;
        document.head.appendChild(style);
    }

    // Function to run all actions after the page is fully loaded
    window.onload = function() {
        injectStyle();
        removeElementsByDynamicPattern();
        removeElementByXPath('//*[@id="document-wrapper"]/div[1]/div');

        // Observe for future DOM changes
        observer.observe(document.body, { childList: true, subtree: true });

        // Additional delayed execution if needed
        delayedExecution();
    };
})();