Greasy Fork

Greasy Fork is available in English.

tiktok-scraper

tiktok dl links scraper

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         tiktok-scraper
// @namespace    http://greasyfork.icu/en/users/14470-sewil
// @version      1.2.2
// @description  tiktok dl links scraper
// @author       Sewil
// @match        https://www.tiktok.com/@*
// @require      https://code.jquery.com/jquery-3.6.0.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/arrive/2.4.1/arrive.js
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tiktok.com
// @grant        none
// @license      MIT
// ==/UserScript==

console.log('tiktok-scraper');
var links = new Set();

var navSelector = '[data-e2e="tiktok-logo"]';
var itemSelector = '[data-e2e="user-post-item"] a';
var linkRegex = /https:\/\/www.tiktok.com\/@[A-Za-z-\d_]+\/video\/\d+/g;
$(document).ready(function () {
    setTimeout(function() {
        $(navSelector).after('<input id="tiktok-scraper_button" type="button" value="DL Links (' + links.size + ')" style="margin-left: 10px;"/>');
        $('#tiktok-scraper_button').on('click', function () {
            var json = [Array.from(links).join('\n')];
            var blob = new Blob(json, { type: 'text/plain;charset=utf-8' });
            var url = window.URL || window.webkitURL;
            var link = url.createObjectURL(blob);
            var a = $('<a />');
            a.attr('download', 'links.txt');
            a.attr('href', link);
            $('body').append(a);
            a[0].click();
            $('body').remove(a);
        });
    }, 2000);
    console.log('tiktok-scraper ready');
    $(itemSelector).each(handleLink);
    $(document).arrive(itemSelector, handleLink);
    function handleLink() {
        var link = $(this).attr('href');
        console.log('handleLink', link);
        if (!link.match(linkRegex)) return;
        links.add(link);
        $('#tiktok-scraper_button').val(
            'DL Links (' + links.size + ')'
        );
    }
});