Skip to content

Instantly share code, notes, and snippets.

View deansimcox's full-sized avatar
💡
I love lamp

Dean deansimcox

💡
I love lamp
View GitHub Profile
@deansimcox
deansimcox / js-sorting.ts
Last active February 21, 2025 07:45
JS Sorting
const jsObjectToSort = {b: 2, c: {d: 4, a: 0}, a: 1};
// Recursively sort js object keys
function sortObjectByKey(obj) {
let sortedObj = {};
Object.keys(obj).sort().forEach(key => {
sortedObj[key] = (typeof obj[key] === 'object' && !Array.isArray(obj[key])) ? sortObjectByKey(obj[key]) : obj[key];
});
return sortedObj;
}
@deansimcox
deansimcox / yt-remove-watch-later.js
Last active October 17, 2024 06:32
Some JS that will go through your Watch Later playlist on Youtube, and remove items sequentially
/**
* Works on your watch later playlist `/playlist?list=WL`
* Update NUMBER_OF_LATEST_VIDEOS_TO_KEEP if you want to keep more/less than the 20 most recent videos
*/
const NUMBER_OF_LATEST_VIDEOS_TO_KEEP = 60;
async function doThing(vidArray) {
for (const vid of vidArray) {
vid.click();