Skip to content

Instantly share code, notes, and snippets.

@dclamage
Created August 12, 2024 03:39
Show Gist options
  • Save dclamage/702859bb91b04884dfaeba6e1c441cd9 to your computer and use it in GitHub Desktop.
Save dclamage/702859bb91b04884dfaeba6e1c441cd9 to your computer and use it in GitHub Desktop.
Extract TikTok comments from current page
// ==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