tiktok-scraper

tiktok dl links scraper

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         tiktok-scraper
// @namespace    https://greasyfork.org/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 + ')'
        );
    }
});