Greasy Fork is available in English.

tiktok-scraper

tiktok dl links scraper

  1. // ==UserScript==
  2. // @name tiktok-scraper
  3. // @namespace https://greasyfork.org/en/users/14470-sewil
  4. // @version 1.2.2
  5. // @description tiktok dl links scraper
  6. // @author Sewil
  7. // @match https://www.tiktok.com/@*
  8. // @require https://code.jquery.com/jquery-3.6.0.js
  9. // @require https://cdnjs.cloudflare.com/ajax/libs/arrive/2.4.1/arrive.js
  10. // @icon https://www.google.com/s2/favicons?sz=64&domain=tiktok.com
  11. // @grant none
  12. // @license MIT
  13. // ==/UserScript==
  14.  
  15. console.log('tiktok-scraper');
  16. var links = new Set();
  17.  
  18. var navSelector = '[data-e2e="tiktok-logo"]';
  19. var itemSelector = '[data-e2e="user-post-item"] a';
  20. var linkRegex = /https:\/\/www.tiktok.com\/@[A-Za-z-\d_]+\/video\/\d+/g;
  21. $(document).ready(function () {
  22. setTimeout(function() {
  23. $(navSelector).after('<input id="tiktok-scraper_button" type="button" value="DL Links (' + links.size + ')" style="margin-left: 10px;"/>');
  24. $('#tiktok-scraper_button').on('click', function () {
  25. var json = [Array.from(links).join('\n')];
  26. var blob = new Blob(json, { type: 'text/plain;charset=utf-8' });
  27. var url = window.URL || window.webkitURL;
  28. var link = url.createObjectURL(blob);
  29. var a = $('<a />');
  30. a.attr('download', 'links.txt');
  31. a.attr('href', link);
  32. $('body').append(a);
  33. a[0].click();
  34. $('body').remove(a);
  35. });
  36. }, 2000);
  37. console.log('tiktok-scraper ready');
  38. $(itemSelector).each(handleLink);
  39. $(document).arrive(itemSelector, handleLink);
  40. function handleLink() {
  41. var link = $(this).attr('href');
  42. console.log('handleLink', link);
  43. if (!link.match(linkRegex)) return;
  44. links.add(link);
  45. $('#tiktok-scraper_button').val(
  46. 'DL Links (' + links.size + ')'
  47. );
  48. }
  49. });