Greasy Fork is available in English.
5chがちょっと見やすくなるやつ
当前为
// ==UserScript==
// @name あ
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 5chがちょっと見やすくなるやつ
// @author おれ
// @match *://*.5ch.net/test/read.cgi/*/*/*
// @match *://*.5ch.net/*/subback.html
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
const TIMER = 0; // ページを更新する間隔をミリ秒単位で指定。不要なら0を指定してください
// 自動アンカー
window.autoanker = function (num) {
let message = document.getElementsByClassName("formelem maxwidth")[2];
message.value += `>>${num}`;
// 自動スクロール
let targetRect = message.getBoundingClientRect();
let targetTop = targetRect.top + window.pageYOffset;
window.scrollTo({
top: targetTop,
behavior: 'smooth'
})
}
// クラシック版に飛ばす
let path = location.pathname;
if (path.indexOf('read.cgi') > -1) {
let paths = path.split('/');
if (paths[3] != 'c') {
let newpath = `/test/read.cgi/c/${paths[3]}/${paths[4]}/${paths[5]}`;
location.pathname = newpath;
}
}
// すべてのリンクをクラシック版へ
let links = document.links;
for (let i = 0; i < links.length; i++) {
let thread = links[i].href.split('/');
let endpoint = thread[2] + '/' + thread[3] + '/' + thread[4];
let regexp = /.*5ch\.net\/test\/read.cgi/;
if (regexp.test(endpoint)) {
links[i].setAttribute('href',`https://${thread[2]}/test/read.cgi/c/${thread[5]}/${thread[6]}/${thread[7]}`);
}
}
// レス番を付与
let post = document.getElementsByClassName("number");
for (let i = 0; i < post.length; i++) {
let anker = Number(post[i].innerHTML);
post[i].setAttribute('onclick',`autoanker(${anker})`);
}
// 自動リロード
if (TIMER != 0) {
setTimeout(function() {
location.reload();
}, TIMER);
}
})();