HIDIVE New GUI Subtitle Editor

Edit inline CSS within the <style id="ds-vtt-styles"> element to invert text from yellow to white

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         HIDIVE New GUI Subtitle Editor
// @version      1.1
// @description  Edit inline CSS within the <style id="ds-vtt-styles"> element to invert text from yellow to white
// @author       slizor659
// @match        https://www.hidive.com/video/*
// @grant        none
// @run-at       context-menu
// @namespace https://greasyfork.org/users/1303801
// ==/UserScript==

// WRITTEN WITH CHATGPT

(function() {
    'use strict';

    // Function to modify the CSS
    function modifyCSS() {
        try {
            const styleElement = document.getElementById('ds-vtt-styles');
            if (styleElement) {
                let cssContent = styleElement.innerHTML;

                if (cssContent) {
                    cssContent = cssContent.replace(/color:#FFFFFF/g, 'color:black')
                                             .replace(/color:#FFFF00/g, 'color:white')
                                             .replace(/color:white/g, 'color:black')
                                             .replace(/color:yellow/g, 'color:white')
                                             .replace(/color:black/g, 'color:yellow');
                    console.log('cssContent after:', cssContent);

                    styleElement.innerHTML = cssContent;
                    console.log('Modified CSS in ds-vtt-styles');

                } else {
                    console.error('The style element does not contain any CSS content.');
                }
            } else {
                console.error('No element with id ds-vtt-styles found.');
            }
        } catch (error) {
            console.error('An error occurred while modifying the CSS:', error);
        }
    }

    // Run the function to modify the CSS
    modifyCSS();

})();