5ch_nanashi_auto2

5ちゃんねるのデフォルトの名前を自動入力する。

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        5ch_nanashi_auto2
// @namespace   https://catherine.v0cyc1pp.com/5ch_nanashi_auto2.user.js
// @include     http://*.5ch.net/*
// @include     https://*.5ch.net/*
// @author      greg10
// @run-at      document-idle
// @license     GPL 3.0
// @version     2.0
// @grant       none
// @description 5ちゃんねるのデフォルトの名前を自動入力する。
// ==/UserScript==
console.log("5ch_nanashi_auto2 start");

function main() {
    var str = document.location + "";
    //console.log("str=" + str);

    document.querySelectorAll("input[name='FROM']").forEach(function(elem) {
        elem.style.borderColor = "red";

        var classname = elem.className;
        //console.log("classname=" + classname);


        // 板のHTMLでは、クッキーが反映されて名前が自動入力されるので、ここでは処理不要
        // https://matsuri.5ch.net/morningcoffee/
        // スレッドのHTML(classname === "formelem maxwidth")ではクッキーが反映されないので、ここで設定する。
        // https://matsuri.5ch.net/test/read.cgi/morningcoffee/1550444800/l50
        if (classname === "formelem maxwidth") {
            if (str.indexOf("morningcoffee") != -1) {
                elem.value = "名無し募集中。。。";
            } else if (str.indexOf("livejupiter") != -1) {
                elem.value = "風吹けば名無し";
            } else if (str.indexOf("kitchen") != -1) {
                elem.value = "北風 #vZp6OYj3";
            } else {}
        }

    });

}

main();


var observer = new MutationObserver(function(mutations) {
    observer.disconnect();
    main();
    observer.observe(document, config);
});

var config = {
    attributes: false,
    childList: true,
    characterData: false,
    subtree: false
};

observer.observe(document, config);