Greasy Fork is available in English.

Copy Modified URL on Click TikTok

Copies vxtiktok links into your clipboard. Will make you share TikTok videos easier on platforms like Telegram and Discord.

  1. // ==UserScript==
  2. // @name Copy Modified URL on Click TikTok
  3. // @match https://www.tiktok.com/*
  4. // @description Copies vxtiktok links into your clipboard. Will make you share TikTok videos easier on platforms like Telegram and Discord.
  5. // @license MIT
  6. // @version 0.0.1.20230708182127
  7. // @namespace https://greatest.deepsurf.us/users/1122038
  8. // ==/UserScript==
  9. (function() {
  10. 'use strict';
  11.  
  12. // Function to handle the document click event
  13. function handleClick(event) {
  14. // Get the current URL
  15. var currentURL = window.location.href;
  16.  
  17. // Modify the URL to use "vxtiktok.com"
  18. var modifiedURL = currentURL.replace(/^(https?:\/\/)(www\.)?([^\/]+)/i, "$1www.vxtiktok.com");
  19.  
  20. // Copy the modified URL to the clipboard
  21. navigator.clipboard.writeText(modifiedURL)
  22. .then(function() {
  23. console.log('Modified URL copied to clipboard:', modifiedURL);
  24. })
  25. .catch(function(error) {
  26. console.error('Failed to copy the modified URL:', error);
  27. });
  28. }
  29.  
  30. // Add a click event listener to the document
  31. document.addEventListener('click', handleClick);
  32. })();