Linux.do Watermark Neo

Force watermark username to 'neo'

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

Advertisement:

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.

ستحتاج إلى تثبيت إضافة مثل 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();
    }
})();