// ==UserScript== // @name 蝦皮短網址 // @namespace https://greasyfork.org/zh-TW/scripts/457084 // @match *shopee.tw/* // @author czh/XPRAMT // @icon https://www.google.com/s2/favicons?sz=64&domain=shopee.tw // @run-at document-start // @license GNU GPLv3 // @description 網址只留下識別碼 // @version 1.0 // @downloadURL none // ==/UserScript== (function() { 'use strict'; var ShortURL=location.href; // Create a button var CopyButton = document.createElement('button'); CopyButton.className = 'CopyButton'; // Add your custom class tSCitv CopyButton.setAttribute('aria-label', 'Copy'); CopyButton.textContent = 'Short URL'; // 设置按钮样式 CopyButton.style.backgroundColor = 'white'; CopyButton.style.border = 'none'; CopyButton.style.fontSize = '15px'; CopyButton.style.lineHeight = '0px'; CopyButton.style.cursor = 'pointer'; // Add button click event CopyButton.addEventListener('click', function() { navigator.clipboard.writeText(ShortURL); CopyButton.textContent = 'Copied!'; setTimeout(function() { CopyButton.textContent = 'Short URL'; }, 1000); // Add your custom button click behavior here }); setTimeout(function() { var flexContainer = document.querySelector('.flex.items-center.V5X-KA');// Find the target flex container if (flexContainer) {// Check if the flex container exists flexContainer.appendChild(CopyButton);//注入按鈕 var utm = location.href.match(/\?.*\=.*/) if (utm == null){ return }else{ ShortURL = location.href.replace(/\?.*\=.*/, ""); } var url = location.href.match(/\/.*-i.\d+.\d+\?/) if (url == null){ return }else{ ShortURL = location.href.replace(/.*-i.(\d+).(\d+)/, "product/$1/$2"); } var url2 = ShortURL.match(/\?.*\=.*/) if (url2 == null){ return }else{ ShortURL = 'shopee.tw/' + ShortURL.replace(/\?.*\=.*/, ""); } }}, 3000); })();