HIDIVE New GUI Subtitle Editor

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

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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();

})();