S3 Mobile Style

S3简单适配手机版网页

目前為 2019-09-06 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         S3 Mobile Style
// @namespace    https://github.com/ipcjs
// @version      1.0.1
// @description  S3简单适配手机版网页
// @author       ipcjs
// @match        *://ac.stage3rd.com/*
// @grant        GM_addStyle
// @grant        GM.addStyle
// @require      https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
// @run-at       document-start
// ==/UserScript==
var css = "@charset \"UTF-8\";\n#top_PageLink select,\n#top_PageLink + td select,\n.showpage td select, ._forumTopicList_asp .PageSubject > td:nth-child(1), ._forumTopicList_asp .rowbg1 > td:nth-child(1),\n._forumTopicList_asp .rowbg2 > td:nth-child(1), ._forumTopicList_asp .PageSubject > td:nth-child(4), ._forumTopicList_asp .rowbg1 > td:nth-child(4),\n._forumTopicList_asp .rowbg2 > td:nth-child(4), ._forumTopicList_asp .rowbg1 > td:nth-child(2) .button_page,\n._forumTopicList_asp .rowbg1 > td:nth-child(2) img,\n._forumTopicList_asp .rowbg2 > td:nth-child(2) .button_page,\n._forumTopicList_asp .rowbg2 > td:nth-child(2) img, ._forumTopicRead_asp form[name=\"w\"] tr:nth-child(1) > td:nth-child(1), ._forumTopicRead_asp form[name=\"w\"] tr:nth-child(2) > td:nth-child(1), ._forumTopicRead_asp form[name=\"w\"] tr:nth-child(4) > td:nth-child(1), ._forumTopicRead_asp form[name=\"w\"] tr:nth-child(5) > td:nth-child(1), ._forumTopicRead_asp .TopicBg1 div[align=\"right\"],\n._forumTopicRead_asp .TopicBg2 div[align=\"right\"], ._forumTopicRead_asp .TopicBg1 > tbody > tr > td:nth-child(2) tr:nth-child(1) > td:nth-child(2) > a,\n._forumTopicRead_asp .TopicBg2 > tbody > tr > td:nth-child(2) tr:nth-child(1) > td:nth-child(2) > a {\n  display: none; }\n\n._forumTopicRead_asp .TopicBg1 > tbody > tr > td:nth-child(2) tr:nth-child(1) > td:nth-child(1),\n._forumTopicRead_asp .TopicBg2 > tbody > tr > td:nth-child(2) tr:nth-child(1) > td:nth-child(1) {\n  white-space: nowrap; }\n\n#main > table:nth-child(2) tr:nth-child(2) td:nth-child(1), ._forumTopicList_asp .PageSubject > td:nth-child(3), ._forumTopicList_asp .rowbg1 > td:nth-child(3),\n._forumTopicList_asp .rowbg2 > td:nth-child(3), ._forumTopicList_asp .PageSubject > td:nth-child(5), ._forumTopicList_asp .rowbg1 > td:nth-child(5),\n._forumTopicList_asp .rowbg2 > td:nth-child(5) {\n  white-space: nowrap;\n  text-overflow: ellipsis;\n  overflow: hidden; }\n\n._forumTopicRead_asp form[name=\"topicReplys\"] .TopicBg1 > tbody > tr > td:first-child,\n._forumTopicRead_asp form[name=\"topicReplys\"] .TopicBg2 > tbody > tr > td:first-child,\n._forumTopicRead_asp #main > .TopicBg1 > tbody > tr > td:first-child,\n._forumTopicRead_asp #main > .TopicBg2 > tbody > tr > td:first-child, ._forumTopicRead_asp form[name=\"topicReplys\"] .TopicBg1 > tbody > tr > td:first-child > div,\n._forumTopicRead_asp form[name=\"topicReplys\"] .TopicBg2 > tbody > tr > td:first-child > div,\n._forumTopicRead_asp #main > .TopicBg1 > tbody > tr > td:first-child > div,\n._forumTopicRead_asp #main > .TopicBg2 > tbody > tr > td:first-child > div {\n  width: 50px !important;\n  font-size: 0px; }\n\n._forumTopicRead_asp form[name=\"topicReplys\"] .TopicBg1 > tbody > tr > td:first-child img,\n._forumTopicRead_asp form[name=\"topicReplys\"] .TopicBg2 > tbody > tr > td:first-child img,\n._forumTopicRead_asp #main > .TopicBg1 > tbody > tr > td:first-child img,\n._forumTopicRead_asp #main > .TopicBg2 > tbody > tr > td:first-child img {\n  width: 40px; }\n\n/* 全局 */\n#main {\n  width: 100% !important; }\n\ntable {\n  table-layout: fixed; }\n\n/* 首尾页签 */\n#top_PageLink,\n#top_PageLink + td,\n.showpage td {\n  display: flex;\n  justify-content: center;\n  align-items: center;\n  width: 100%; }\n  #top_PageLink > .button_nopage,\n  #top_PageLink + td > .button_nopage,\n  .showpage td > .button_nopage {\n    flex: auto; }\n\n/* 列表页面 */\n._forumTopicList_asp .rowbg1 > td:nth-child(2),\n._forumTopicList_asp .rowbg2 > td:nth-child(2) {\n  font-size: 0px; }\n  ._forumTopicList_asp .rowbg1 > td:nth-child(2) a,\n  ._forumTopicList_asp .rowbg2 > td:nth-child(2) a {\n    font-size: 16px; }\n\n._forumTopicList_asp .PageSubject > td:nth-child(3), ._forumTopicList_asp .rowbg1 > td:nth-child(3),\n._forumTopicList_asp .rowbg2 > td:nth-child(3) {\n  width: 50px; }\n\n._forumTopicList_asp .PageSubject > td:nth-child(5), ._forumTopicList_asp .rowbg1 > td:nth-child(5),\n._forumTopicList_asp .rowbg2 > td:nth-child(5) {\n  width: 70px; }\n\n/* 详细页面 */\n._forumTopicRead_asp #main > .TopicBg1 + table.TopicBg1 {\n  visibility: hidden; }\n\n._forumTopicRead_asp .topic_msg img[loaded] {\n  width: 100%; }\n";

const log = console.log.bind(console, `[${GM_info.script.name}]`);

function setupMeta() {
    //<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> 
    const $meta = document.createElement('meta');
    $meta.name = 'viewport';
    $meta.content = 'initial-scale=1.0, user-scalable=no';
    document.head.appendChild($meta);
}

function setupStyle() {
    // 设置rootClass, 方便对具体页面设置css
    const rootClass = location.pathname.replace(/[\/.]/g, '_');
    document.documentElement.className += ` ${rootClass}`;
    log('rootClass:', rootClass);
    GM.addStyle(css.toString());
}

setupMeta();
setupStyle();