WeatherStar Patcher 1.1

Patches WeatherStar sites to make them feel more like the Weather Channel.

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         WeatherStar Patcher 1.1
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Patches WeatherStar sites to make them feel more like the Weather Channel.
// @             Patch update 1.1: Added 3000+ compatibility. Fixed number string still showing.
// @match        https://weatherstar.netbymatt.com/*
// @match        https://weatherstar3000.netbymatt.com/*
// @grant        none
// @license GNU GPLv3
// ==/UserScript==

(function() {
    'use strict';

    // === Replace most WeatherStar traces (as in title, logo, etc) and replaces with Weather Channel ===

    // Text replacing
    function replaceText(find, replace) {
        const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null, false);
        let node;
        while ((node = walker.nextNode())) {
            node.textContent = node.textContent.replace(new RegExp(find, 'gi'), replace);
        }
    }

    // Replace text phrases with Weather Channel
    replaceText('Weatherstar', 'The Weather Channel');
    replaceText('Weather Star', 'The Weather Channel');
    replaceText('WeatherStar', 'The Weather Channel');
    replaceText('4000\\+', '‎'); // Remove the 4000 string
    replaceText('3000\\+', '‎'); // Remove the 3000 string
    replaceText('V1.0.4', '‎'); // Remove the 3000 version string
    replaceText('v6.2.6', '‎'); // Remove the 4000 version string
    replaceText('\\+', '‎'); // FINALLY REMOVES PLUS! YAYYYY :) (patched in 1.1)
    replaceText('WeatherStar 4000\\+', 'The Weather Channel');

    // Change the webpage title from Weatherstar to Weather Channel
    document.title = 'The Weather Channel [weatherstar patch]';

    // Replace the logo in the top left to say Weather Channel
    const logoURL = 'https://i.ibb.co/FLDPTdNG/weather-channel-logo-85-67.png';

    function updateImages() {
        // Select only the correct logo in the HTML (this was patched in 0.1.1)
        const logoImgs = document.querySelectorAll('.header .logo img');

        logoImgs.forEach(img => {
            // Only change if the image source is originally a WeatherStar logo (this was patched in 1.1)
            if (img.src.includes('logo') || img.src.match(/weatherstar|weather-star|4000/i)) {
                img.src = logoURL;
            }
        });
    }

    setInterval(updateImages, 500);
    updateImages();

})();