rizuwan86 / Shopee Collection ID Navigator

// ==UserScript==
// @name         Shopee Collection ID Navigator
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Navigasi koleksi Shopee guna butang Prev dan Next
// @author       Rizuwan
// @match        https://shopee.com.my/collections/*
// @license MIT
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    function createButton(label, offset, topOffset) {
        const button = document.createElement("button");
        button.textContent = label;
        button.style.position = "fixed";
        button.style.top = topOffset + "px";
        button.style.right = "20px";
        button.style.zIndex = "99999";
        button.style.padding = "10px 15px";
        button.style.backgroundColor = "#ee4d2d";
        button.style.color = "#fff";
        button.style.border = "none";
        button.style.borderRadius = "6px";
        button.style.cursor = "pointer";

        button.onclick = function () {
            const url = window.location.href;
            const match = url.match(/collections\/(\d+)/);

            if (match && match[1]) {
                const currentId = parseInt(match[1]);
                const newId = currentId + offset;
                const newUrl = `https://shopee.com.my/collections/${newId}`;
                window.location.href = newUrl;
            } else {
                alert("Tak jumpa ID koleksi dalam URL.");
            }
        };

        document.body.appendChild(button);
    }

    // Button Next (atas)
    createButton("➡️ Next", 1, 40);

    // Button Prev (bawah sikit)
    createButton("⬅️ Prev", -1, 90);
})();