Created
August 12, 2024 03:39
-
-
Save dclamage/702859bb91b04884dfaeba6e1c441cd9 to your computer and use it in GitHub Desktop.
Extract TikTok comments from current page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Extract TikTok Comments | |
// @namespace http://tampermonkey.net/ | |
// @version 2024-05-29 | |
// @description Extracts TikTok Comments | |
// @author Rangsk | |
// @match https://www.tiktok.com/@rangsk.wordle/video/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=tiktok.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
window.extractComments = function() { | |
const comments = []; | |
const commentElements = document.querySelectorAll('.css-1i7ohvi-DivCommentItemContainer'); | |
commentElements.forEach((element) => { | |
const spans = element.querySelectorAll('span'); | |
const username = spans[1].innerText; | |
const text = spans[2].innerText; | |
comments.push(`[t] ${username} - ${text}`); | |
}); | |
return comments.join('\n'); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment