Skip to content

Commit

Permalink
add a couple more userscripts
Browse files Browse the repository at this point in the history
  • Loading branch information
joshparkerj committed Feb 29, 2024
1 parent f555b0b commit f2175a7
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
25 changes: 25 additions & 0 deletions butterflies/comments.js
Original file line number Diff line number Diff line change
@@ -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}`,
}
)),
);
48 changes: 48 additions & 0 deletions twitch/directory-filter.user.js
Original file line number Diff line number Diff line change
@@ -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);
}());

0 comments on commit f2175a7

Please sign in to comment.