Skip to content

Instantly share code, notes, and snippets.

View nirlanka's full-sized avatar

Nir Lanka nirlanka

  • SGX
  • Singapore
View GitHub Profile
@nirlanka
nirlanka / webnovel_download_command_history.sh
Last active January 29, 2025 21:50
webnovel downloader - golang
## DEV SH
mkdir golang_one
cd golang_one
go mod init golang_one
# go run golang_one
go get -u github.com/chromedp/chromedp
## Program the app
mkdir output
go run golang_one "DC新氪星 - DC New Krypton" '.content_read>.box_con>.bookname>h1' '.content_read>.box_con>#content' '#pager_next' https://www.shuhaige.net/130382/78521659.html
cd output
@nirlanka
nirlanka / epub_to_reader.go
Created January 25, 2025 17:43
Extract html files from .epub files and move the content into .json files, including a list of files
package main
import (
"archive/zip"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
"slices"
@nirlanka
nirlanka / yt-download.sh
Created August 21, 2024 06:20
Download from YouTube (as channel member)
pipenv shell # should have yt-dlp installed
yt-dlp --write-subs --sub-lang en --convert-subs srt --sub-format txt --cookies-from-browser chrome <VIDEO-OR-PLAYLIST-URL>
# https://apple.stackexchange.com/questions/434686/how-to-get-cookies-txt-for-youtube-from-safari
@nirlanka
nirlanka / download.sh
Last active August 21, 2024 03:26
Download stream from m3u8 playlist
ffmpeg -i https://<SITE>/playlist/<ID>=.m3u8 -codec copy "<FILENAME>.mkv"
// Source: https://superuser.com/questions/1705706/how-can-m3u8-and-ts-streams-or-videos-properly-be-saved-without-any-pixelated
@nirlanka
nirlanka / youtube-all-videos-to-playlist.js
Last active July 15, 2024 03:55
(YouTube) Create a playlist from a channel with all its videos
// 1. Create a new playlist
// 2. Load all video thumbnails in channel in required order (scroll down until the end)
// 3. Run script:
{
const ll=document.querySelectorAll('yt-icon-button.dropdown-trigger.style-scope.ytd-menu-renderer #button'); // all videos' menu buttons
let i=0;
function loop() {
ll[i].click(); // open menu
document.querySelectorAll('tp-yt-paper-listbox ytd-menu-service-item-renderer')[2].click(); // click Add to Playlist
setTimeout(() => {
@nirlanka
nirlanka / replace-static-page-content.js
Last active May 30, 2020 14:48
Replace body of current static page with another page (without reload) (Note: In this page, <header> isn't considered to change except the <title>. Also, this will mess up the back button, unless you handle window 'popstate' yourself.)
(function() {
if (fetch && Promise && document.querySelector && history) { // <-- Dependencies. Otherwise normal links will remain.
function loadPage(url) {
fetch(url).then(function (res) {
return res.text();
}).then(function(html) {
var dom = new DOMParser().parseFromString(html, 'text/html');
var title = dom.querySelector('title').innerText;
history.pushState({}, title, url);
document.title = title;
@nirlanka
nirlanka / simple-html-tokeniser.js
Last active April 24, 2020 03:31
Simple tokenizer examples
`<div>
Some text here
<div>
<h3>Lorem <a href="./abc/def.html">ipsum</a></h3>
<p>Dolor sit</p>
<p>amet</p>
</div>`
.split(/([<>\s="\/]{1})/g)
.map(s=>s.trim())
.filter(Boolean)
@nirlanka
nirlanka / index.html
Last active March 29, 2020 08:38
Simple & clean web component inner-element handling
<!DOCTYPE html>
<html>
<body>
<x-one></x-one>
<script src="./x-one.js"></script>
</body>
</html>
@nirlanka
nirlanka / index.html
Created January 2, 2020 08:32
Web component experiment
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<x-one>
<p>Lorem ipsum</p>
Dolor sit amet
</x-one>
@nirlanka
nirlanka / README.md
Last active December 23, 2019 12:49
Nim on Windows (e.g.)

This is just how Nim compilation to C looks like in Windows.

nim-eg