36rain页面适配插件

脚本持续更新中...

目前為 2024-08-17 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name                36rain页面适配插件
// @name:zh-CN          36rain页面适配插件
// @namespace           http://36rain.com
// @version             1.5
// @description:zh-CN   脚本持续更新中...
// @match               http://36rain.com/*
// @match               http://www.36rain.com/*
// @run-at              document-start
// @license             MIT
// @grant               GM_info
// @grant               GM_getValue
// @grant               GM_setValue
// @grant               GM_deleteValue
// @grant               GM_xmlhttpRequest
// @grant               GM_registerMenuCommand
// @grant               GM_openInTab
// @grant               GM_notification
// @grant               GM_addStyle
// @grant               GM_log
// @grant               GM_getResourceText
// @grant               GM_getResourceURL
// @grant               GM_listValues
// @grant               GM_addValueChangeListener
// @grant               GM_removeValueChangeListener
// @grant               GM_setClipboard
// @grant               GM_getTab
// @grant               GM_saveTab
// @grant               GM_getTabs
// @grant               GM_download
// @description 脚本持续更新中...
// ==/UserScript==



/*
    Author: 无名布女 
    Greasyfork: Put your Greasyfork profile page URL here.
*/


(function() {
    'use strict';

    const customCSS = `
    	body, html {
      	    font-size: 30px !important;
      	    line-height: 150% !important;
    	}
        .input {
            font-size: 36px !important;
            height: 60px !important;
            margin-bottom: 40px !important;
        }
        .user-infoWrap2, .user-infoWrap2 * {
          line-height: 150% !important;
          font-size: 24px !important;
        }
    	.tr3 * {
            line-height: 150% !important;
        }
        .f10, .f10 * {
            font-size: 30px !important;
        }
        .tiptop, .tiptop * {
            font-size: 30px !important;
            line-height: 100% !important;
            margin-top: 20px !important;
            margin-bottom: 20px !important;
        }
        .listinline {
            display: none !important;
        }
	    .t3 span {
            display: block !important;
            text-align: left !important;
            margin-top: 0.5em !important; /* Optional: Adds some space between spans */
            font-size: 40px !important;
        }
        #breadcrumbs {
            display: none;
        }
        #breadcrumbs .crumbs-item {
            background: none;
        }
        .h {
            background: none !important;
        }
        .user-pic {
            margin-top: 10px !important;
            margin-bottom: 10px !important;
            margin-right: auto !important;
            margin-left: auto !important;
        }
        .pages {
            height: auto;
            line-height: 100% !important;
            margin-bottom: 20px;
            padding-top: 5px;
            padding-bottom: 5px;
            border: none !important;
        }
        .hthread {
            height: auto;
        }
        .pages ul .pagesone {
            background: none !important;
            border: none !important;
            
        }
        .tpc_content, tpc_content * {
            border-top: 2px dashed #ccc !important;
            padding: 3em 2em 2em 2em !important;
        }
        .tr2, .tr2 * {
            height: auto;
            line-height: 150% !important;
            margin-bottom: 20px;
            background: none !important;
        }
        .f14 * {
            font-size: 36px !important;
            letter-spacing: normal !important;
            line-height: 200% !important;
        }
        .f14 h6, .f14 h6 * {
            font-size: inherit !important;
        }
        .f14 blockquote, .f14 blockquote * {
            font-size: 36px !important;
            width: 100% !important;
            letter-spacing: normal !important;
            line-height: 200% !important;
        }
	    .guide {
            line-height: 150% !important;
        }
        .btn {
            font-size: 30px !important;
        }
        #post-option span { 
            width: 100% !important;
        }
        .tipad, .signature, .tipad *, .signature * {
            font-size: 24px !important;
        }          
    `;

    function applyStyles() {
        var elements = document.querySelectorAll('.f14 *:not(h6):not(h6 *)');
        elements.forEach(function(el) {
            el.style.setProperty('font-size', '36px', 'important');
            el.style.setProperty('letter-spacing', 'normal', 'important');
            el.style.setProperty('line-height', '200%', 'important');
        });

        var f10elements = document.querySelectorAll('.f10 *');
        f10elements.forEach(function(el) {
            el.style.setProperty('font-size', '30px', 'important');
        });

        var h2elements = document.querySelectorAll('.h2, .h2 *');
        h2elements.forEach(function(el) {
            el.style.setProperty('height', '36px', 'important');
            el.style.setProperty('background', 'none', 'important');
        });

        var h1elements = document.querySelectorAll('.h1, .h1 *');
        h1elements.forEach(function(el) {
            el.style.setProperty('font-size', '36px', 'important');
            el.style.setProperty('letter-spacing', 'normal', 'important');
            el.style.setProperty('line-height', '150%', 'important');
        });

        // Apply styles to user-infoWrap2 elements
        var userInfoElements = document.querySelectorAll('.user-infoWrap2, .user-infoWrap2 *');
        userInfoElements.forEach(function(el) {
            el.style.setProperty('font-size', '24px', 'important');
	    el.style.setProperty('line-height', '150%', 'important');
        });

    var userLoginElement = document.getElementById('user-login');
    if (userLoginElement) {

        userLoginElement.style.setProperty('width', '200%', 'important');
        userLoginElement.style.setProperty('display', 'block', 'important');
        userLoginElement.style.setProperty('font-size', '36px', 'important');
    }

    var InfoElement = document.getElementById('infobox');
    if (InfoElement) {
        InfoElement.style.setProperty('margin-top', '120px', 'important');
    }

    var UserInfoElement = document.getElementById('user_info');
    if (UserInfoElement) {
        UserInfoElement.style.setProperty('width', '48%', 'important');
    }

    // Retain specific <li> elements inside #guide
    var guideElement = document.getElementById('guide');
    guideElement.style.setProperty('line-height', '150%', 'important');
    guideElement.style.setProperty('display', 'block', 'important');
    if (guideElement) {
        var liElements = guideElement.querySelectorAll('li');
        liElements.forEach(function(li) {
            if (li.id !== 'h_index' && li.id !== 'h_search') {
                /* li.remove(); */
                li.style.setProperty('display', 'none', 'important');
            }
        });
    }

    // Precise removal of the target <td> element
    var tdToRemove = document.querySelector('#main > form:nth-child(21) > div > table > tbody > tr:nth-child(3) > td:nth-child(1)');
    if (tdToRemove) {
        console.log("TD to be removed:", tdToRemove.outerHTML); // Debugging the TD before removal
        tdToRemove.style.setProperty('display', 'none', 'important');
        console.log("Removed the td element successfully.");
    } else {
        console.error("Target TD element was not found.");
    }

    var ChangeTPCContent = document.querySelectorAll('.tpc_content, .tpc_content *');
    ChangeTPCContent.forEach(function(el) {
        el.style.setProperty('padding-top', '3em', 'important');
    });

    // Change width of the specified <td> element
    var tdToChangeWidth = document.querySelector('#main > form:nth-child(21) > div > table > tbody > tr:nth-child(3) > td:nth-child(2)');
    if (tdToChangeWidth) {
        tdToChangeWidth.style.setProperty('width', '100%', 'important'); // Change width to 70%
    } else {
        console.error("Target TD element to change width was not found.");
    }

    // Remove all <img> elements inside <th> elements
    var thElements = document.querySelectorAll('.tr3 th');
    thElements.forEach(function(th) {
        var imgElement = th.querySelector('img');
        if (imgElement) {
            console.log("IMG element found and will be removed:", imgElement.outerHTML);
            imgElement.style.setProperty('display', 'none', 'important');
            console.log("IMG element removed.");
        }
    });

    // Change the margin of the specified element
    var divToChangeMargin = document.querySelector('#main > form:nth-child(5) > div > div:nth-child(4) > div:nth-child(1)');
    if (divToChangeMargin) {
        divToChangeMargin.style.setProperty('margin', '20px', 'important'); // Change margin to desired value
        console.log("Changed margin of the element.");
    } else {
        console.error("Target element to change margin was not found.");
    }

    // Change the width of the specified element
    var divToChangeWidth = document.querySelector('#main > form:nth-child(5) > div > div:nth-child(4) > div:nth-child(1) > div');
    if (divToChangeWidth) {
        divToChangeWidth.style.setProperty('width', '100%', 'important'); // Change margin to desired value
        console.log("Changed margin of the element.");
    } else {
        console.error("Target element to change margin was not found.");
    }

    // Change the width of the specified element
    var divToChangeWidthInput = document.querySelector('#main > form:nth-child(5) > div > div:nth-child(4) > div:nth-child(1) > div > input');
    if (divToChangeWidthInput) {
        divToChangeWidthInput.style.setProperty('width', '75%', 'important'); // Change margin to desired value
        divToChangeWidthInput.style.setProperty('float', 'right', 'important'); // Change margin to desired value
        console.log("Changed margin of the element.");
    } else {
        console.error("Target element to change margin was not found.");
    }

    var spanToChangeFloat = document.querySelector('#main > form:nth-child(5) > div > div:nth-child(4) > div:nth-child(1) > div > span.fr.gray');
    if (spanToChangeFloat) {
        spanToChangeFloat.style.setProperty('float', 'left', 'important'); // Change margin to desired value
        console.log("Changed margin of the element.");
    } else {
        console.error("Target element to change margin was not found.");
    }

    // Combine styles for #editor-tab and #editor-tool
    var editorElements = ['#editor-tab', '#editor-tool', 
        '#editor-button > div:nth-child(3) > div'];
    editorElements.forEach(function(selector) {
        var element = document.querySelector(selector);
        if (element) {
            element.style.setProperty('font-size', '16px', 'important');
            // element.style.setProperty('height', '150%', 'important');
        }
    });
    var editorFooterElements = ['#main > form:nth-child(5) > div > table:nth-child(9) > tbody > tr:nth-child(2) > th > div > div', '#post-option > div > div'];
    editorFooterElements.forEach(function(selector) {
        var element = document.querySelector(selector);
        if (element) {
            element.style.setProperty('margin-left', '0px', 'important');
        }
    });

    var inputElements = document.querySelectorAll('textarea, input, select');
    inputElements.forEach(function(input) {
        if (input) {
            input.style.setProperty('font', '30px Arial', 'important');
        }
    });

    var ChangePtypeWidth = document.querySelector('#main > form:nth-child(5) > div > div:nth-child(4) > div:nth-child(1) > div > span.fr.gray > select');
    if (ChangePtypeWidth) {
        ChangePtypeWidth.style.setProperty('width', 'auto', 'important');
    }

    var ChangeFooterFontSize = document.querySelector('#footer > div');
    if (ChangeFooterFontSize) {
        ChangeFooterFontSize.style.setProperty('font-size', '10px', 'important');
        ChangeFooterFontSize.style.setProperty('line-height', '100%', 'important');
    }

    // change color of some elements
    var ElementsToChangeColor = [
        '#user-login > a:nth-child(3)', '#user-login > a:nth-child(4)',
        '#h_index > a > font', '#h_search > a > font', 
    ]
    ElementsToChangeColor.forEach(function(selector) {
        var element = document.querySelector(selector);
        if (element) {
            element.style.setProperty('color', '#000', 'important');
        }
    });

    var ElementsToChangeSize = ['#h_index > a > font', '#h_search > a > font'];
    ElementsToChangeSize.forEach(function(selector) {
        var element = document.querySelector(selector);
        if (element) {
            element.style.setProperty('font-size', '42px', 'important');
        }
    });

}

    // Create and append style element
    var style = document.createElement('style');
    style.textContent = customCSS;
    document.head.appendChild(style);

    // Apply styles immediately
    applyStyles();

    // Apply styles to dynamically loaded content
    var observer = new MutationObserver(function(mutations) {
        applyStyles();
    });
    observer.observe(document.body, { childList: true, subtree: true });

    document.addEventListener('DOMContentLoaded', function() {
        applyStyles();
    });

    // Force a repaint
    document.body.style.display='none';
    document.body.offsetHeight;
    document.body.style.display='';

})();