HF Anti-Caps Lock

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==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) {

        }
    });
})();