HF Anti-Caps Lock

Automatically convert the words in caps lock in thread titles to Title Case.

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         HF Anti-Caps Lock
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Automatically convert the words in caps lock in thread titles to Title Case.
// @author       James
// @include      https://hackforums.net/search.php?*
// @include      https://hackforums.net/forumdisplay.php?*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let result_rows = document.querySelectorAll("tr.inline_row");

    result_rows.forEach(function(row) {
        try {
            let thread_name = "";
            if (window.location.href.indexOf("search.php") > -1) {
                thread_name = row.querySelector('.subject_new').innerText;
            }
            else {
                thread_name = row.querySelector('.mobile-link > div > span > span > a').innerText;
            }
            //console.log(thread_name);

            let thread_name_titlecase = thread_name.replace(/\w\S*/g, function(txt) {
                if (txt === txt.toUpperCase()) {
                    return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
                }
                else {
                    return txt;
                }
            });

            if (window.location.href.indexOf("search.php") > -1) {
                row.querySelector('.subject_new').innerText = thread_name_titlecase;
            }
            else {
                row.querySelector('.mobile-link > div > span > span > a').innerText = thread_name_titlecase;
            }
        }
        catch (err) {

        }
    });
})();