diff --git a/butterflies/comments.js b/butterflies/comments.js new file mode 100644 index 0000000..69fef10 --- /dev/null +++ b/butterflies/comments.js @@ -0,0 +1,25 @@ +JSON.stringify( + x.filter(({ source_type: type }) => type === 'post_comment') + .map(( + { + post_comment_id: id, + post_comments: { + posts: { + description: post, + slug, + }, + body: comment, + post_comments: replies, + }, + receiver_profile: { username }, + }, + ) => ( + { + username, + post, + comment, + reply: replies[0]?.body, + link: `https://www.butterflies.ai/users/${username}/p/${slug}?comment_id=${id}`, + } + )), +); diff --git a/twitch/directory-filter.user.js b/twitch/directory-filter.user.js new file mode 100644 index 0000000..00d8780 --- /dev/null +++ b/twitch/directory-filter.user.js @@ -0,0 +1,48 @@ +// ==UserScript== +// @name filter by viewers +// @namespace http://tampermonkey.net/ +// @version 2024-02-29 +// @description hide the channels that have more viewers than a certain amount +// @author Josh Parker +// @match https://www.twitch.tv/directory/all +// @icon https://www.google.com/s2/favicons?sz=64&domain=twitch.tv +// @grant none +// ==/UserScript== + +(function filterByViewers() { + const moOptions = { + subtree: true, + childList: true, + }; + + const bodyMoCallback = function bodyMoCallback(_, mutationObserver) { + const directoryContainer = document.querySelector('[data-target="directory-container"]'); + console.log(directoryContainer); + if (!directoryContainer) { + console.log('will retry'); + return; + } + + const moCallback = function moCallback() { + const dataTargets = directoryContainer + .querySelectorAll('.tw-tower > [data-target]'); + dataTargets.forEach((dataTarget) => { + const twMediaCardStat = dataTarget.querySelector('.tw-media-card-stat'); + if ( + twMediaCardStat.textContent.match(/\dK/i) + || twMediaCardStat.textContent.match(/\d{3}/) + || twMediaCardStat.textContent.match(/[4-9]\d/) + || twMediaCardStat.textContent.match(/39/) + ) dataTarget.style.setProperty('display', 'none'); + }); + }; + + const mo = new MutationObserver(moCallback); + mo.observe(directoryContainer, moOptions); + + mutationObserver.disconnect(); + }; + + const bodyMo = new MutationObserver(bodyMoCallback); + bodyMo.observe(document.body, moOptions); +}());