tiktok-scraper

tiktok dl links scraper

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(У мене вже є менеджер скриптів, дайте мені встановити його!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

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

console.log('tiktok-scraper');
var links = {};

var navSelector = "a[data-e2e='tiktok-logo']";
var parentSelector =
    '#app > div.tiktok-ywuvyb-DivBodyContainer.e1irlpdw0 > div.tiktok-w4ewjk-DivShareLayoutV2.enm41490 > div > div.tiktok-xuns3v-DivShareLayoutMain.ee7zj8d4 > div.tiktok-1qb12g8-DivThreeColumnContainer.eegew6e2 > div';
var selector =
    parentSelector +
    '> div > div.tiktok-x6f6za-DivContainer-StyledDivContainerV2.eq741c50 > div > div > a';
$(document).ready(function () {
    $(navSelector).after(
        $(
            '<input id="tiktok-scraper_button" type="button" value="DL Links (0)" style="margin-left: 10px;"/>'
        )
    );
    $('#tiktok-scraper_button').on('click', function () {
        var json = [Object.keys(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);
    });
    console.log('tiktok-scraper ready');
    $(selector).each(handleLink);
    $(document).arrive(selector, function () {
        $(selector).each(handleLink);
    });
    function handleLink() {
        var link = $(this).attr('href');
        console.log(link);
        links[link] = '';
        $('#tiktok-scraper_button').val(
            'DL Links (' + Object.keys(links).length + ')'
        );
    }
});