Boosty Title Modifier

Modify Boosty title with timestamp

目前为 2024-07-25 提交的版本。查看 最新版本

// ==UserScript==
// @name         Boosty Title Modifier
// @version      0.2
// @description  Modify Boosty title with timestamp
// @match        https://boosty.to/*
// @grant        none
// @namespace https://gf.qytechs.cn/users/789838
// ==/UserScript==

(function() {
    'use strict';

    var appliedChange = false;

    // Функция для получения текста из элемента с классом, содержащим CreatedAt_headerLink_
    function getTimestamp() {
        var timestampElement = document.querySelector('span[class*="CreatedAt_headerLink_"]');
        if (timestampElement) {
            console.log("Timestamp element found:", timestampElement);
            return timestampElement.textContent.trim().replace(/ в /g, ' ').replace(/:/g, ' ');
        } else {
            console.log("Timestamp element not found.");
        }
        return '';
    }

    // Функция для изменения заголовка страницы
    function modifyTitle() {
        var originalTitleElement = document.querySelector('h1[class*="Post_title_"]');
        if (originalTitleElement) {
            console.log("Title element found:", originalTitleElement);
            var originalTitle = originalTitleElement.textContent.trim();
            var timestamp = getTimestamp();
            if (timestamp !== '') {
                document.title = timestamp + ' - ' + originalTitle;
                console.log("Title modified to:", document.title);
                appliedChange = true;
            } else {
                console.log("Timestamp is empty.");
            }
        } else {
            console.log("Title element not found.");
        }
    }

    // Проверка и вызов функции каждые 5 секунд до применения изменений
    var intervalId = setInterval(function() {
        if (!appliedChange) {
            modifyTitle();
        } else {
            clearInterval(intervalId);
        }
    }, 5000);

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址