Last active
July 31, 2023 18:16
-
-
Save rafalimaz/1762e6ee355a03220208a2762f2dc25d to your computer and use it in GitHub Desktop.
Javascript automations
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
function youtubeSpeed(rate) { | |
document.getElementsByClassName("video-stream html5-main-video")[0].playbackRate = rate; | |
} | |
function y(rate) { | |
youtubeSpeed(rate) | |
} | |
function saveAllPosts() { | |
const postIdsSaved = JSON.parse(localStorage.getItem('allPosts')) || []; | |
const postsToSave = document.querySelectorAll("a[id*='thread_title']") | |
let postIdsToSave = Array.from(postsToSave).map(post => post.id).filter(function(id) { | |
return postIdsSaved.indexOf(id) === -1 | |
}) | |
postIdsToSave = postIdsSaved.concat(postIdsToSave); | |
localStorage.setItem('allPosts', JSON.stringify(postIdsToSave)) | |
} | |
function markAllPosts(weight) { | |
getAllPosts()?.forEach(a => { a ? a.style.fontWeight = weight : null }) | |
} | |
function getAllPosts() { | |
const posts = localStorage.getItem('allPosts') | |
const postIds = JSON.parse(posts) | |
return postIds.map(id => document.getElementById(id)) | |
} | |
function g() { | |
return getAllPosts() | |
} | |
function s() { | |
saveAllPosts() | |
} | |
function n() { | |
markAllPosts('normal') | |
} | |
function b() { | |
markAllPosts('bold') | |
} | |
n() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment