Skip to content

Instantly share code, notes, and snippets.

View senthilmpro's full-sized avatar

Senthil Muthuvel senthilmpro

View GitHub Profile
@senthilmpro
senthilmpro / youtube channel all videos as playlist userscript.js
Last active September 16, 2024 14:49
youtube channel all videos as playlist userscript
// ==UserScript==
// @name yt-channel-playlist
// @namespace http://tampermonkey.net/
// @version 2024-09-15
// @description try to take over the world!
// @author senthilmpro
// @match https://www.youtube.com/@*
// @match https://www.youtube.com/*/
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant none
@senthilmpro
senthilmpro / yt-channel-as-playlist.js
Created September 15, 2024 04:25
youtube channel all videos as playlist
// go to channel home page (not any other subtab)
// open developer tools - console.
// paste the following.
let scripts = Array.from(document.querySelectorAll('script'));
let script = scripts.filter(x => x.innerHTML?.includes('externalId'))
let channelId = script[0]?.innerHTML.split("externalId")[1].split(",")[0]?.replace(":", '')?.replaceAll('"', '');
let playlistUrl = null;
@senthilmpro
senthilmpro / dir-change.sh
Last active August 3, 2024 16:59
dir-change.sh
# shorthand to navigate your folders
# add this to ~/.zshrc
# then run "source ~/.zshrc"
# usage "dir music"
# "dir dl"
dir() {
local user=$(whoami)
local folder="$1"
@senthilmpro
senthilmpro / youtube-play-all-playlist.js
Last active April 27, 2024 04:40
youtube channel play all videos as playlist
let cId = document.querySelector('[itemprop="identifier"]').content;
const getPlaylistId = () => {
let cId = document.querySelector('[itemprop="identifier"]').content;
if(cId?.startsWith('UC')) return 'UU' + cId.slice(2);
else return null;
}
const getPlaylistUrl = () => {
let channelId = getPlaylistId();
@senthilmpro
senthilmpro / telegram-channel-dl.js
Created March 10, 2024 15:32
telegram-channel-dl.js
// download
let counter = 0;
let prefix = "TamilFreakers";
const LAST_INDEX = 1210; // get the message Id of last message (right click on the latest post, "copy message link".. this should have latest message id")
let messages = Array(LAST_INDEX).fill(0).map((x, i) => `message${i + 1}`).reverse();
let textContents = [];
let htmlContents = [];
@senthilmpro
senthilmpro / convert-image-url-to-base64.js
Created March 10, 2024 15:30
Image URL to base64 using javascript
// snippet from google gemini
function convertImageURLToBase64(imageUrl) {
fetch(imageUrl)
.then(response => response.blob())
.then(blob => {
const reader = new FileReader();
reader.readAsDataURL(blob);
reader.onloadend = function() {
const base64data = reader.result;
@senthilmpro
senthilmpro / logger.js
Created September 7, 2023 16:34
Winston Logger colorize using Node.js (code snippet)
// open terminal -> "npm install winston -S"
const winston = require('winston');
// snippet from https://stackoverflow.com/questions/51012150/winston-3-0-colorize-whole-output-on-console
let alignColorsAndTime = winston.format.combine(
winston.format.colorize({
all:true
}),
winston.format.label({
label:'[LOGGER]'
@senthilmpro
senthilmpro / git-log-color.sh
Created August 7, 2023 19:42
git log (color)
git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --branches
## source: https://dev.to/pradumnasaraf/beautify-your-git-log-with-a-single-command-2i5
@senthilmpro
senthilmpro / read-id3-tags-nodejs.js
Created January 27, 2023 22:55
read ID3 tags of Mp3 using Node.js
const id3 = require('id3-reader');
// readTags('/path/to/test.mp3');
const readTags = async (filePath) => {
try {
const tags = await id3.read(filePath);
console.log(tags);
return tags;
} catch (error) {
console.error(error);
@senthilmpro
senthilmpro / zip-directory.js
Created July 26, 2021 17:51
zip-directory-in-nodejs
const fs = require('fs');
const archiver = require('archiver');
const path = require('path');
// inspired from https://stackoverflow.com/questions/15641243/need-to-zip-an-entire-directory-using-node-js
const zipDirectory = (dirPath, outputFile = "target.zip") => {
const dPath = path.resolve(dirPath);
var output = fs.createWriteStream(outputFile);
const archive = archiver('zip');