Add Links back to IP2Always

Add old links back to IP2Always

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Add Links back to IP2Always
// @namespace   Violentmonkey Scripts
// @match       https://communities.win/c/ip2always
// @match       https://communities.win/c/ip2always/active
// @match       https://communities.win/c/ip2always/new
// @match       https://communities.win/c/ip2always/rising
// @match       https://communities.win/c/ip2always/top
// @grant       none
// @version     1.0.2
// @license     MIT
// @author      Tammer
// @description Add old links back to IP2Always
// ==/UserScript==

(function() {
    'use strict';

    function addLinks() {
        // Find menu div
        let menuDiv = document.querySelector('.sc-1ifomfq-5.cKDyLg');

        if (!menuDiv) {
            console.log("Menu not found, retrying...");
            setTimeout(addLinks, 500); // Try again after 1 second
            return;
        }

        // Prevent duplicate injection
        if (document.getElementById('custom-links-container')) {
            return;
        }

        // Create a new div for links
        let linksContainer = document.createElement('div');
        linksContainer.id = 'custom-links-container';
        linksContainer.style.position = "absolute";
        linksContainer.style.marginTop = "-1.5pt";
        linksContainer.style.marginLeft = "200px";

        // Define links
        let links = [
            { text: "HOT", url: "https://communities.win/c/ip2always" },
            { text: "ACTIVE", url: "https://communities.win/c/ip2always/active" },
            { text: "NEW", url: "https://communities.win/c/ip2always/new" },
            { text: "RISING", url: "https://communities.win/c/ip2always/rising" },
            { text: "TOP", url: "https://communities.win/c/ip2always/top" }

        ];

        // Generate links and append links
        links.forEach(linkData => {
            let link = document.createElement('a');
            link.href = linkData.url;
            link.textContent = linkData.text;
            link.style.marginRight = "20px";
            link.style.fontSize = "17px"
            link.style.letterSpacing = "2pt"
            linksContainer.appendChild(link);
        });

        // Append links next to mew existing stupid dropdown menu
        menuDiv.appendChild(linksContainer);
    }

    // Run script when DOM is fully loaded
    window.addEventListener('load', addLinks);
})();