Greasy Fork

Shopee 悬浮按钮

添加快捷入口

目前为 2023-07-01 提交的版本。查看 最新版本

// ==UserScript==
// @name         Shopee 悬浮按钮
// @namespace    http://tampermonkey.net/
// @version      1.1.2
// @license      GPL Rayu
// @description  添加快捷入口
// @author       Rayu
// @match        https://seller.shopee.tw/*
// @grant        none
// @require      http://code.jquery.com/jquery-3.6.0.min.js
// ==/UserScript==

(function() {
    'use strict';

    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/products/analysis/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/marketing/pas/new' }
    ];

    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 === 'button6' ? '_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;
        }

        .product-statistic .shopee-table[data-v-25858b04]{
            width: 1750px !important;
        }

        /* 在特定URL生效的样式 */
        body.route-portal-marketing-pas-assembly #app > div.app-container > div > div {
            margin-left: 30px;
        }
    `;
    document.head.appendChild(customStyle);
})();