spacepaste

  1.  
  2. // ==UserScript==
  3. // @name aliexpress copy link
  4. // @namespace none
  5. // @description add a copy clean link button
  6. // @include https://www.aliexpress.com/item/*
  7. // @version 2
  8. // @run-at document-idle
  9. // @grant GM_setClipboard
  10. // @grant GM_addStyle
  11. // ==/UserScript==
  12. var container = document.body.getElementsByClassName("product-action-main")[0];
  13. var copy_button = document.createElement("a");
  14. copy_button.className = "copy_button product_action_main";
  15. var html_index = window.location.href.indexOf(".html")
  16. var clean_url = "https://www.aliexpress.com/item/a/" + window.location.href.substring(html_index - 11, html_index) + ".html"
  17. copy_button.onclick = function () {
  18. GM_setClipboard(clean_url);
  19. };
  20. 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 };")
  21. copy_button.href = "javascript:;"
  22. container.appendChild(copy_button);
  23.