令S1正确显示AA的油猴脚本
本帖最后由 冰箱研会长e-3M 于 2021-1-12 21:43 编辑https://greasyfork.org/zh-CN/scripts/420012-aa-for-s1
不需要手动输入了...
-------------
删除了GITHUB和GITEE的仓库, 下面的链接基本都作废了.
这里可以安装最新版
试着用XPATH重新写了一遍, 有好好在工作呢(
// ==UserScript==
// @name AA for S1
// @namespace http://tampermonkey.net/
// @version 0.3
// @updateURL https://gitee.com/Arxher/AA-For-Stage1st/raw/main/AA4S1.user.js
// @downloadURLhttps://gitee.com/Arxher/AA-For-Stage1st/raw/main/AA4S1.user.js
// @descriptionModify Stage1 text property for AA
// @author 冰箱研会长
// @match https://bbs.saraba1st.com/2b/*
// @grant GM_addStyle
// ==/UserScript==
var AA_author_array = new Array("冰箱研会长e-3M","冰箱研会长");
function getElementByXpath(path) {
return document.evaluate(path, document, null,
XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}
function Reset_BlockCode(NodeRoot){
var CodeBlocks = NodeRoot.getElementsByClassName("blockcode");
if(CodeBlocks){
for(var i = 0; i < CodeBlocks.length;i++){
var CodeBlock=CodeBlocks;
CodeBlock.style.fontSize="12px";
CodeBlock.style.lineHeight="22px";
CodeBlock.style.fontFamily="Monaco, Consolas, Lucida Console, Courier New, serif";
CodeBlock.style.whiteSpace = "normal";
}
}
}
function Reset_BlockQuote(NodeRoot){
var QuoteBlocks = NodeRoot.getElementsByClassName("blockquote");
if(QuoteBlocks){
for(var i = 0; i < QuoteBlocks.length;i++){
var QuoteBlock=QuoteBlocks;
QuoteBlock.style.fontSize="12px";
QuoteBlock.style.lineHeight="22px";
QuoteBlock.style.fontFamily="Monaco, Consolas, Lucida Console, Courier New, serif";
QuoteBlock.style.whiteSpace = "pre-wrap";
}
}
}
function AAPosts_Modifier(){
var PostLists = getElementByXpath(`/html/body/div/div/div`);
if(PostLists){
//existence check
if(PostLists.id == `mdly`){
//if this is your thread, the xpath of threadlist will be 8 4 3
//8 4 2 will have id "mdly"
PostLists = getElementByXpath(`/html/body/div/div/div`);
if(PostLists){
//check if new postlists exist, if so, append normal procedure but for 842
var PostCounter = 1;
while(getElementByXpath(`/html/body/div/div/div/div[${PostCounter}]`)){
var PostAuthor = getElementByXpath(`/html/body/div/div/div/div[${PostCounter}]/table/tbody/tr/td/div/div/div/a`);
if(PostAuthor){
if( AA_author_array.includes(PostAuthor.innerText) ){
var ReplyBox = getElementByXpath(`/html/body/div/div/div/div[${PostCounter}]/table/tbody/tr/td/div/div/div/table/tbody/tr/td`);
ReplyBox.style.fontSize = "14px";
ReplyBox.style.lineHeight = "8px";
ReplyBox.style.fontFamily = "aahub, MS PGothic";
ReplyBox.style.whiteSpace = "pre";
Reset_BlockCode(ReplyBox);
Reset_BlockQuote(ReplyBox);
}
}
PostCounter = PostCounter + 1;
}
}
}else{
//this is not your thread, so normal 842 will be active
var PostCounter = 1;
while(getElementByXpath(`/html/body/div/div/div/div[${PostCounter}]`)){
var PostAuthor = getElementByXpath(`/html/body/div/div/div/div[${PostCounter}]/table/tbody/tr/td/div/div/div/a`);
if(PostAuthor){
if( AA_author_array.includes(PostAuthor.innerText) ){
var ReplyBox = getElementByXpath(`/html/body/div/div/div/div[${PostCounter}]/table/tbody/tr/td/div/div/div/table/tbody/tr/td`);
ReplyBox.style.fontSize = "14px";
ReplyBox.style.lineHeight = "8px";
ReplyBox.style.fontFamily = "aahub, MS PGothic";
ReplyBox.style.whiteSpace = "pre";
Reset_BlockCode(ReplyBox);
Reset_BlockQuote(ReplyBox);
}
}
PostCounter = PostCounter + 1;
}
}
}
}
AAPosts_Modifier();
-------------------
项目GITHUB地址
一键安装! GITEE版本无需翻墙, 就是可能我会忘记同步, 所以版本有落后一点...
一键安装!可能需要翻墙
请先确认浏览器有安装Tampermonkey或者其他userscript引擎.
简单更新了一下, 之前的版本启用之后,“对整个S1的影响, 不可估量”,
所以这次的版本的逻辑就是
1. 建立一个 "发布AA的人" 的id列表
2. 找到他们发的贴子
3. 对他们的帖子内容进行修饰
学习JS已经半天的我给出的代码是这样的, 诸君感觉有喷点不用藏着掖着, 指出来就当帮我进步了.
// ==UserScript==
// @name AA for S1
// @namespace http://tampermonkey.net/
// @version 0.g
// @descriptionModify Stage1 text property for AA
// @author 冰箱研会长
// @match https://bbs.saraba1st.com/2b/*
// @grant GM_addStyle
// ==/UserScript==
var AA_author_array = new Array("冰箱研会长e-3M","冰箱研会长");
// 在这里加入发布AA的人的ID
function AAPosts_Modifier(NodeRoot){
var PostLists = NodeRoot.getElementById("postlist");
var PostTables = PostLists.getElementsByClassName("plhin");
for (var i=0;i< PostTables.length;i++){
var PostTable = PostTables;
if(AA_author_array.includes( PostTable.getElementsByClassName("pls favatar").
getElementsByClassName("authi").
getElementsByTagName("a").
innerText)){
//PostTable.getElementsByClassName("t_fsz").style.color = "#022c80";
PostTable.getElementsByClassName("t_fsz").style.fontSize = "14px";
PostTable.getElementsByClassName("t_fsz").style.lineHeight = "8px";
PostTable.getElementsByClassName("t_fsz").style.fontFamily = "aahub, MS PGothic";
PostTable.getElementsByClassName("t_fsz").style.whiteSpace = "pre";
Reset_BlockCode(PostTable.getElementsByClassName("t_fsz"));
}
}
}
//专门用来重置代码块的函数... 这个实现直觉上让我觉得好笨
function Reset_BlockCode(NodeRoot){
var CodeBlocks = NodeRoot.getElementsByClassName("blockcode");
for(var i = 0; i < CodeBlocks.length;i++){
var CodeBlock=CodeBlocks;
//CodeBlock.style.color="#022c80";
CodeBlock.style.fontSize="12px";
CodeBlock.style.lineHeight="22px";
CodeBlock.style.fontFamily="Monaco, Consolas, Lucida Console, Courier New, serif";
CodeBlock.style.whiteSpace = "normal";
}
}
AAPosts_Modifier(document)
---因为/标签会刷新掉脚本做的修改所以手动打出来的更新分界线---
本来是不想发这个帖子, 想着日后真的要弄一个AA串的话, 就写在主楼的,
但是我在编辑草稿(测试)的时候点错直接发出来了, 所以将错就错了...
脚本是很简单的, 用GM_addStyle方法把S1的t_fsz的 样式 修改为适合显示AA的样式就完事了.
脚本一共用了两个字体AAHUB和MS PGothic, 后者系统应该会自带.
现在, 没弄明白的是启用脚本之后, 代码块的行距会变得异常的大, CSS我不是了解的很清楚, 不知道有没有巨巨指教一下
代码如下:
// ==UserScript==
// @name AA for S1
// @namespace http://tampermonkey.net/
// @version 0.e
// @descriptionModify Stage1 text property for AA
// @author 冰箱研会长
// @match https://bbs.saraba1st.com/2b/*
// @grant GM_addStyle
// ==/UserScript==
GM_addStyle ( `
.t_fsz {
font-family: aahub,MS PGothic;
white-space: pre;
font-size: 14px;
line-height: 8px;
}
`);
去TamperMoneky里新建脚本, 复制粘贴之后刷新页面, 应该就可以看到下方正确显示的AA画了.
(PC ONLY)
i| | i| / _ -ニニ=- _ // __
i| | ∨ _-ニニニニニニ- _ , / |、 ―=ミ 、
i| | | j/ニニニニニニニニ- __ _,/ / _jニ〉 ./ \
i| | | _-ニニニニニ-=<_¨⌒ ー==‐/ / __ -ニア /  ̄ ̄>x、
:, i| | 〈ニニニニニ=-----――へ、_/ /_ -=ニニニニニニア / / _/-=ニニニ\
′ , ∨/ , ヘ_jニニニ‐'" ___ -=ニア'厂/ /ニニニニニニニニア _/ / . /ニニ=-  ̄ ̄`
∧ ∨ ∨/ / /)=ァ ̄_ -ニニニニニニ=‐'" ∨./ニニニニニニ=- ----=<_ ̄ ̄ < //-  ̄ -===―'⌒
/∧ ∨ ∨/ _j _∠斗ニニ=-―――<_ 、 / /¨ -弌ニニア´ __ z――― __`弌ix、 `く _ -ニ- __¨__<ニニ
、 ∨/ _厂ア´-ニニニニ- i圦. \ 、\ ( ̄ ' / _厂 _ ___/ /ア´/⌒)x マ_)hx \_/ニニニニニ
、\ 弌__,厂 -=ニニニ厂 | 、(\xf示ト、 j// ̄x┐ /⌒ア´ ノ |/___/⌒)x ( ̄)x ⌒!~ <ニニニニ
\ 、弌ニニニニア / i|. j_x=、/ Vソ| iト、 |(__厂 j/ . イ ∠ ア⌒丁>=- 寸{ }i ∧ `寸ニニ
__ -=ニ)hx 寸ニニニニ7j| ./ i| 圦 v) | l|个 | \./ / / / ∠=- 厂ニ/ ,i V ∧ |ニ 〈\ 寸ニ
` -ニニニニニ)hx 寸-¨下弌i|/ 八 、 乂V 、 / / ./ / ∠ --=<ニ/_∠i| 〈ニ| .|ニ |ニニ⌒ニニ
`¨¨¨¨¨¨弌ニニ)x 寸∧ニニ寸ニ‐| 厂个 _`_/ __j/ 厂- _ | i| \/ j'" __  ̄\| i|ニ| i|ニ |ニニニニニ
^寸ニ)x 寸ニニニニ{ 〈ニア 厂⌒j厂/ .イニニニ! { | く\/ニニ7⌒>x / 八i |ニ マニニニニ
x/ ̄ ̄ ⌒)x`弌-=ニニ {〈 { _/Z / i|ニ( ̄`寸x `く| ( -ニニニニ|/ /∨ /ニ| !' ノニニニニ
___)\_ ( 〈 / /)hx `弌i厂) Ⅵ j厂 ____/} 厂}\ `⌒>圦 ___`寸ニ| j=- イ ∨ _ イニニニニニ
ニニニ-_ `弌L_ / ̄_ イ厂 i|)hx `弌x\ ̄ /]/ニ〈 {\ [/ /ノ `、 弌=- __(ニニニ| ,ニニニニニニ厂
寸ニニニニ-_ 寸/ /ア´ / | { ≧=- _` __ [_/.ア^弌_ \{/ {ノ \ ー― (_厂〉 | /ニニニニ- j/
マニニニニ} 乂 //i| { .〉i圦 i| ≧=― / |/ 、 ⌒7 〈 /〉 )hx__ イニノ ⌒!ニ=- /
. マニニ[__] |i/ 乂! 、 八_jk | _/ / / i| ノ__/〈 /ニニニ=- __ 彡 / __ノ/⌒> /
.}ニニニニ| i〈 ( ゝ ト、 \[ ̄,ノ、\ _____厂_∧ 、 / /| 〈⌒ア 寸ニニニ| マニニニ| jN/ |_ア^>'" _ <
.}ニニニニ| |个x弌=--=彡厂ア二\ \―― ア //ニi\___j{ i|| /⌒ix `弌ニニ| マニ=- / L=- <  ̄ ̄
./ニニニニi| |ニニ{≧z--<ニ/ > `ー//i |ニニニ八 i|| 寸-x 寸=- ___. -=彡 >'" __/ ir‐=< \
/ニニニ厂 ̄ ]寸_乂_厂ア/ /厂ア/| .人寸ニニ{ \ 、 寸ニx `ー=====―'"´____ ア⌒i| | \ 、
./ニニニニニ≧=-----=≦ニ′ |∧[/} j 寸 7^弌乂_ \ \`弌ニ=------=≦ニニニjア |ト、 \ `、
ニニニニニニニニニニニニ{ | / {  ̄`寸ix ` -\ \ 弌x ` < / _ -='" 八 \ `、 j!
`寸ニニニニニニニニニ厂/ i| | .∧ { ⌒ -ニ=- 寸x、` ⌒ ̄  ̄ ̄ ̄__∠/ イ `、 V∧|
\ 寸ニニニニニニニニ/ i| i|__ -=- {\ `弌\_>ニ=―――― __彡' _ -ニ ∨|
ニニ)x -==ニニニニニ/____jL -==-⌒ 、 `、 \  ̄ ̄ ̄ アZ-=≦ニニニア´ /ニア´ ∠=-ニニ 、 } Ⅵ
ニニニ=― __ ィ⌒厂 , 、 `、 `¨¨ア¨¨⌒ `寸ニニア´ /ニア´ _. 彡ニニニニ〉 ∨ ∧ jノ
≧=――――=⇒'" / | ′ 丶、 `、 / 、 i|ニニア ∠=‐'" _ -ニニニニニニニ/ /__ ∧ |
ニニニニニア´ ./ | ', /{ `、 /| `、 /-ア '"´ _-ニニニニニニニニニア} 「⌒∨| |
`マニニニニi{ ′ 、 / 乂 ∨| `弌/ _ -ニニニニニニニニニニア } | j__厂
. }ニニニニ 、 , iL___ `弌{  ̄ 八 厂 _ -ニニニニニニニニニニニイ j/⌒´
マニニニニ\ { 「 ̄\ ___j / / _ -ニニニニニニニニニニ> '| ノ
寸ニニニニ/` { __〉 丶、___厂 / /_ -ニニニニニニニニニニ‐ .ノ ∧
` ―=/ ー< ̄∧ __/ __ ,___//ニニ‐  ̄ ̄ ー‐ ∠_/
. 〈____厂 ̄ 、 〈::::/ /::::\ , -====j /=-
/\ ∧:' /::::::::::::::::>'
,.-、 ,,-‐、
| :`ヽ、 ,..--..,, ,,.--‐'" |
| ゞ''"" ヾ /
! ,.' |
‐‐┼- ;
‐┼- ● ● ー┼-
.‐十 ‐┼-
- ヽ、 (_人_) ゙メ、
_______ ` 、 ヽ_ノ /
/ \/ ヽ /、
/ ,.. -‐‐- 、 \ ヽ
}∠,..艦__これ_ \ \ `、
/.:.:.:./ \|\:.:.:.\\ , / ./|
.(二)i:/n n\i:.:.:.:.i‘, } ./ ./ .|
. i:人| U U l:.:.:Λ:‘,/ ./ ./ |
<人( u ,':.:./´ヽ:.:´ ./ ./ |
/:.个: . __▽__ ,./:∠:.ヽ ヽ ./ ./ .|
{:.:.:‘, ....| | | ヽ ヽ _ノ ./ .|
人:.:.:.: .| | | ノi:.:.ヽ _ _ ノ |
`¨¨´. .| | | `、_,.ノ |
| | | |
| | | |
| | | |
_| |_ ', |
く´ヽ| |/`ゝ 、 /
| |`-∞-´{`l { ┬┬┬┬ ,′
ヽ!__ ___{O | .| .|| | ,
ノ | | ̄| | |ヽ | | .|| .| .|
\|_|_|_|_|_/ } | || .| |
|_| |_| ノ | ヽ_`| ヽ──、
」.| 」.| ` ー┘ `└一 ' ̄ ̄´
? 手机端看就是一团乱码 S1间距还是太大,AA看着跟糊了一样 恶魔娘阿洛 发表于 2021-1-2 11:18
S1间距还是太大,AA看着跟糊了一样
是的 其实字距还好说 行距真的大了一截 角色脖子都会变长.... 实话说还是很反人类啊,都2021年了不能整点正常的图吗 楼主试过开着脚本浏览其它正常帖子吗
平时还是要禁用,看AA时再开 酥蕤 发表于 2021-1-2 11:38
楼主试过开着脚本浏览其它正常帖子吗
平时还是要禁用,看AA时再开
平时还是要禁用的, 特定帖子开一下..
我是JS小白, 等我升升级说不定就能写出来更人性化的脚本了. 冰箱研会长e-3M 发表于 2021-1-2 11:23
是的 其实字距还好说 行距真的大了一截 角色脖子都会变长....
我没理解,行距大了的话你降低line-height不就行了吗? cxf5102 发表于 2021-1-2 15:00
我没理解,行距大了的话你降低line-height不就行了吗?
是啊... 我做的就是
1. 改变字体
2. 调整到合适的大小
3. 调整行距
1 2 可以在discuz内部完成
3 需要脚本
但我想直接用脚本一起实现了... 这样咋说... 方便点吧
顺便学学JS DOM? 赶2ch超5ch指日可待啊 呃,我直接理解错你的意思了。如果是你想解决代码块行距太大的问题的话,你加入下面的样式即可。
.pl .blockcode ol li {
white-space: inherit;
}
原因在于你加入的样式使得代码块中行末的<br>多生成了一行。只要你让white-space: pre不影响到代码块的内容就可以了。 cxf5102 发表于 2021-1-2 15:27
呃,我直接理解错你的意思了。如果是你想解决代码块行距太大的问题的话,你加入下面的样式即可。
.pl .bloc ...
感谢> <
原来是white-space的问题, 这下解决了 s1未来的野田大神,慢慢升起
页:
[1]