- // ==UserScript==
- // @name aliexpress copy link
- // @namespace none
- // @description add a copy clean link button
- // @include https://www.aliexpress.com/item/*
- // @version 2
- // @run-at document-idle
- // @grant GM_setClipboard
- // @grant GM_addStyle
- // ==/UserScript==
- var container = document.body.getElementsByClassName("product-action-main")[0];
- var copy_button = document.createElement("a");
- copy_button.className = "copy_button product_action_main";
- var html_index = window.location.href.indexOf(".html")
- var clean_url = "https://www.aliexpress.com/item/a/" + window.location.href.substring(html_index - 11, html_index) + ".html"
- copy_button.onclick = function () {
- GM_setClipboard(clean_url);
- };
- GM_addStyle(".copy_button::before { content: 'Copy';} .copy_button:hover, .copy_button {background-color: #e9003a; color: #fff; padding: 0 30px; margin: 0 5px 5px 0; vertical-align: baseline };")
- copy_button.href = "javascript:;"
- container.appendChild(copy_button);