Greasy Fork is available in English.

Shopee 悬浮按钮

添加快捷入口并移除 Shopee 追踪器

// ==UserScript==
// @name         Shopee 悬浮按钮
// @namespace    http://tampermonkey.net/
// @version      1.4.0.4
// @license      GPL Rayu & Pixmi
// @description  添加快捷入口并移除 Shopee 追踪器
// @author       Rayu & Pixmi
// @match        https://seller.shopee.tw/*
// @exclude      https://seller.shopee.tw/webchat/conversations
// @match        *://shopee.tw/*
// @match        *://shopee.ph/*
// @match        *://shopee.sg/*
// @match        *://shopee.com.my/*
// @icon         https://icons.duckduckgo.com/ip2/shopee.com.ico
// @grant        none
// @require      http://code.jquery.com/jquery-3.6.0.min.js
// @run-at       document-body
// ==/UserScript==

(function() {
    'use strict';

    // 代码1 - 悬浮按钮
    const buttons = [
        { id: 'button1', content: '待<br>出货', link: 'https://seller.shopee.tw/portal/sale/shipment?type=toship' },
        { id: 'button2', content: '我的商品', link: 'https://seller.shopee.tw/portal/product/list/all?page=1&size=48' },
        { id: 'button3', content: '商品分析', link: 'https://seller.shopee.tw/datacenter/product/overview' },
        { id: 'button4', content: '我的广告', link: 'https://seller.shopee.tw/portal/marketing/pas/assembly' },
        { id: 'button5', content: '行销活动', link: 'https://seller.shopee.tw/portal/marketing' },
        { id: 'button6', content: '退貨退款', link: 'https://seller.shopee.tw/portal/sale/return' }
    ];

    const floatingButtonsContainer = document.createElement('div');
    floatingButtonsContainer.id = 'floating-buttons-container';
    document.body.appendChild(floatingButtonsContainer);

    buttons.forEach(button => {
        const buttonElement = document.createElement('a');
        buttonElement.id = button.id;
        buttonElement.className = 'floating-button';
        buttonElement.href = button.link;
        buttonElement.target = button.id === 'button10' ? '_self' : '_blank';
        buttonElement.innerHTML = button.content;
        floatingButtonsContainer.appendChild(buttonElement);
    });

    const customStyle = document.createElement('style');
    customStyle.innerHTML = `
        #floating-buttons-container {
            display: flex;
            flex-direction: column;
            position: fixed;
            top: 50%;
            right: 5px;
            transform: translateY(-50%);
            z-index: 9999;
        }

        .floating-button {
            display: flex;
            align-items: center;
            justify-content: center;
            background-color: rgba(238, 77, 45);
            color: #ffffff;
            width: 50px;
            height: 50px;
            border-radius: 5px;
            font-weight: bold;
            font-size: 18px;
            margin-top: 10px;
            text-align: center;
        }

        /* 添加的样式 */
        .route-portal-marketing-pas-assembly .ads-index,
        .route-portal-marketing-pas .ads-index {
            width: 1800px !important;
        }

        /* 賣家數據中心 */
        .page-content-wrapper.responsive-content-wrapper {
            max-width: 1500px !important;
        }

        /* 广告数据总览 */
        /* 顶栏 */
        .home-header-wrap[data-v-1b6bbf94]{
            justify-content: left !important;
        }

        /* 侧边距 */
        .route-portal-marketing-pas-index .page-container.has-sidebar-panel{
            padding-left: 5px !important;
        }

        .page-content-wrapper{
            margin-left: 60px !important;
        }

        /* 最小宽度 */
        .main-content .list-index[data-v-0fb3e6e7]{
            min-width: 1750px !important;
        }

        /* 公告与建议 */
        .to-do-list-container[data-v-7d956ea7], .top-text-container[data-v-7d956ea7]{
            display: none !important;
        }

        .rcmd-rewards-section[data-v-762b6814]{
            display: none !important;
        }

        /* 详细数据宽度 */
        .module-page-detail[data-v-5f4edcf3] {
            min-width: 1750px!important;
        }

    `;
    document.head.appendChild(customStyle);

    // 代码2 - 移除追踪器
    const URL = window.location.href;
    const urlRegex = new RegExp(/\-i\.([\d]+)\.([\d]+)/);
    if (URL.match(urlRegex)) {
        let match = URL.match(urlRegex);
        window.location.replace(`${window.location.origin}/product/${match[1]}/${match[2]}`);
    } else {
        const rootmatch = document.evaluate('//div[@id="main"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
        const rootnode = rootmatch.singleNodeValue;
        if (rootnode) {
            const callback = (mutationsList, observer) => {
                for (const mutation of mutationsList) {
                    const target = mutation.target;
                    if (target.nodeName !== 'DIV') continue;
                    const links = target.querySelectorAll('a');
                    if (links.length) {
                        for (const link of links) {
                            let match = link.href.match(urlRegex);
                            if (!match) continue;
                            link.href = `${window.location.origin}/product/${match[1]}/${match[2]}`;
                        }
                    } else {
                        const link = target.closest('a') || false;
                        if (!link) continue;
                        let match = link.href.match(urlRegex);
                        if (!match) continue;
                        link.href = `${window.location.origin}/product/${match[1]}/${match[2]}`;
                    }
                }
            }
            const observer = new MutationObserver(callback);
            // start observe
            observer.observe(document.body, {
                attributes: true,
                childList: true,
                subtree: true
            });
        }
    }
})();