Linux.do Watermark Neo

Force watermark username to 'neo'

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

// ==UserScript==
// @name         Linux.do Watermark Neo
// @namespace    http://tampermonkey.net/
// @description  Force watermark username to 'neo'
// @version      1.1
// @match        https://linux.do/*
// @icon         https://linux.do/favicon.ico
// @grant        unsafeWindow
// @run-at       document-start
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const rawAttach = Element.prototype.attachShadow;
    Element.prototype.attachShadow = function(init) {
        if (init && init.mode === 'closed') {
            init.mode = 'open';
            const shadowRoot = rawAttach.call(this, init);
            const style = document.createElement('style');
            style.textContent = 'div { opacity: 0 !important; visibility: hidden !important; pointer-events: none !important; }';
            shadowRoot.appendChild(style);
            return shadowRoot;
        }
        return rawAttach.call(this, init);
    };

    const CONFIG = {
        text: "neo",
        id: "ld-wm-neo-force",
        density: 130,
        intensity: 2,
        angle: -25,
        font: "bold 15px sans-serif"
    };

    function generateWatermark() {
        if (document.getElementById(CONFIG.id)) return;

        const dpr = window.devicePixelRatio || 1;
        const canvas = document.createElement("canvas");
        const size = CONFIG.density * dpr;

        canvas.width = size;
        canvas.height = size;

        const ctx = canvas.getContext("2d");
        ctx.scale(dpr, dpr);
        ctx.translate(CONFIG.density / 2, CONFIG.density / 2);
        ctx.rotate(CONFIG.angle * Math.PI / 180);
        ctx.font = CONFIG.font;
        ctx.textAlign = "center";
        ctx.textBaseline = "middle";
        ctx.fillStyle = `rgb(${CONFIG.intensity}, ${CONFIG.intensity}, ${CONFIG.intensity})`;
        ctx.fillText(`@${CONFIG.text}`, 0, 0);

        const div = document.createElement("div");
        div.id = CONFIG.id;
        div.style.cssText = `
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            z-index: 2147483647;
            pointer-events: none;
            background-image: url(${canvas.toDataURL("image/png")});
            background-repeat: repeat;
            background-size: ${CONFIG.density}px;
            mix-blend-mode: difference;
            opacity: 1;
        `;
        document.body.appendChild(div);
    }

    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', generateWatermark);
    } else {
        generateWatermark();
    }
})();