上下翻转文字

上下翻转页面上的文字,一个有趣无用的脚本

// ==UserScript==
// @name         上下翻转文字
// @namespace    dylanzhang
// @version      0.1
// @description  上下翻转页面上的文字,一个有趣无用的脚本
// @author       Dylan_Zhang
// @match        *://*/*
// @icon         none
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    // 创建全局翻转样式
    const style = document.createElement('style');
    style.textContent = `
        body {
            transform: scaleY(-1); /* 垂直翻转 */
            min-height: 100vh; /* 确保高度适应 */
            margin: 0;
        }

        /* 保持视频/图片正常方向(可选) */
        img, video {
            transform: scaleY(-1);
        }
    `;

    // 插入样式到页面头部
    document.head.appendChild(style);

    // 处理 fixed/fixed 定位元素
    [document.body, ...document.querySelectorAll('*')].forEach(el => {
        if(getComputedStyle(el).position === 'fixed') {
            el.style.transform += ' scaleY(-1)';
        }
    });
})();