Skip to content

Instantly share code, notes, and snippets.

View cocoabox's full-sized avatar

cocoabox cocoabox

View GitHub Profile
@cocoabox
cocoabox / google2duckduckgo.js
Created November 20, 2023 05:56
google 検索結果を duckduckgo に変換するBookmarklet
javascript:(function() { var currentUrl = window.location.href; var searchQueryMatch = currentUrl.match(/q=([^&]+)/); if (searchQueryMatch && searchQueryMatch[1]) { var decodedSearchQuery = decodeURIComponent(searchQueryMatch[1].replace(/\+/g, ' ')); var duckDuckGoUrl = 'https://duckduckgo.com/?t=h_&q=' + encodeURIComponent(decodedSearchQuery); window.location.href = duckDuckGoUrl; } else { window.location.href = 'https://duckduckgo.com/'; } })();
@cocoabox
cocoabox / steal-synopsis-from-amazon-prime-video.js
Created January 11, 2023 16:37
steal-synopsis-from-amazon-prime-video.js
(async function(){
const series_title = document.querySelector('[data-automation-id="title"]')?.innerText.trim();
const series_synop = document.querySelector('[data-automation-id="atf-synopsis"]')?.innerText.trim();
const li_arr = document.querySelectorAll('[id^="av-ep-episodes"]');
let episodes = [];
for (const li of li_arr) {
const title_elem = li.querySelector('[data-automation-id^="ep-title-episodes-"]');
const title_all = title_elem.innerText.trim();
const title_mat = title_all.match(/^([0-9]+)\.*\s*(.*)$/);
@cocoabox
cocoabox / youtube-audio.sh
Last active September 12, 2022 05:31
Download youtube music videos or playlist (with static album art) into m4a file with embedded album art. Requires ffmpeg, AtomicParsley, yt-dlp
#!/bin/bash
if [[ -z "$1" ]]; then
echo "usage : $0 [YOUTUBE_URL_OR_ID]" >&2
exit 1
fi
OK=1
ffmpeg >/dev/null 2>/dev/null
if [[ $? -eq 127 ]]; then
echo "ffmpeg is required : https://ffmpeg.org/download.html" >&2
@cocoabox
cocoabox / twitter-not-interested-bookmarklet.js
Created May 5, 2022 15:37
twitter-not-interested-bookmarklet.js
javascript: void((function() { function disableInterests(doc) { function findSpanText(checkbox) { let elem = checkbox.parentElement; let levels = 0; while (elem && levels < 10) { let span = elem.querySelector('span'); if (span) { return span.textContent; } elem = elem.parentElement; levels++; } } let wait_ms = 100; let checkboxes = doc.querySelectorAll("div > input[type='checkbox']:checked"); let len = checkboxes.length; let done = 0; let inc = 50; checkboxes.forEach((interest) => { console.log(interest); let text = findSpanText(interest); setTimeout(function() { done++; let msg = `(${done}/${len}) ` + (text ? text : '(unknown)'); console.log(msg); doc.title = msg; interest.scrollInt
@cocoabox
cocoabox / fetlife-convert-all-photos-to-private.js
Last active July 12, 2020 10:36
batch convert all FetLife photos to private
// fetLife batch change all photos to private ("friends only")
//
// usage:
//
// 1. open your first photo , URL should be https://fetlife.com/users/xxxxx/pictures/yyyyy
// 2. copy paste this code to your Javascript console and hit Return
// - a new tab (window) will open; do not close this tab
// - to terminate the process, close the newly-opened tab, then reload the current window/tab
// 3. this script doesn't work all the time; to make sure every pic is now private, repeat 1~2 again
//
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ATV="$DIR/atv"
ATV_URL="$DIR/atv-airplay-url"
TMP_DIR="/tmp/play-$RANDOM"
HTTP_SERVER="/usr/local/bin/http-server"
NPM="/usr/local/bin/npm"
if [[ ! -f "$1" ]]; then
javascript:void(function(){function e(e){let i="",o="",t="";return e>3600&&(e-=3600*(i=Math.floor(e/3600)),i=`${i} hrs`),e>60&&(e-=60*(o=Math.floor(e/60)),o=`${o} min`),e&&(t=`${e} sec`),[i,o,t].join(" ").trim()}function i(){window.__close_timer.timer&&window.clearInterval(window.__close_timer.timer),window.__close_timer.timer="",window.__close_timer.active=!1,window.__close_timer.sec=0,window.__close_timer.title=""}if(void 0===window.__close_timer&&(window.__close_timer={}),window.__close_timer.active){let o=e(window.__close_timer.sec);return window.confirm(`%E2%8F%B2 :${o}\n%F0%9F%9A%AB%E2%8F%B2?`)?(document.title=window.__close_timer.title,void i()):void 0}let o="10m",t=document.querySelector("video");if(t){o=e(Math.floor(t.duration-t.currentTime)+5)}let _=window.prompt("%E2%8F%B2%F0%9F%92%A4 %E2%86%92%E2%9D%8C",o).trim();if(!_)return;let r=_.toLowerCase().match(/^(([0-9\.]+)\s*(hours|hour|hrs|hr|h))?\s*(([0-9\.]+)\s*(minute|minute|mins|min|m))?\s*(([0-9\.]+)\s*(seconds|second|secs|sec|s))?$/),n=0;r[2]&&(n
@cocoabox
cocoabox / close-timer.js
Last active April 4, 2020 10:14
close timer bookmarklet
void(function(){
function sec2time_str(sec) {
let h='';
let m='';
let s='';
if (sec > 3600) {
h = Math.floor(sec / 3600);
sec -= 3600*h;
h = `${h} hrs`;
}
@cocoabox
cocoabox / cocoa-twitter-hide-annoying-tweets.js
Last active March 29, 2020 09:10
cocoa-twitter-hide-annoying-tweets.js
// ==UserScript==
// @name cocoa hide twitter annoying "Liked by XX" and "Promoted tweets"
// @namespace cocoabox.twitter.hide_promoted
// @description cocoa hide twitter annoying "Liked by XX" and "Promoted tweets
// @include https://twitter.com/*
// @version 1.0.0
// @run-at document-start
// @grant none
// ==/UserScript==
(function(){
@cocoabox
cocoabox / fuck-video.js
Created March 14, 2020 08:32
bookmarklet that removes annoying video from websites (please minify before use)
( function () {
let words = 'player vid';
words = window.prompt('block what?',words);
words = words.split(' ').map(n=>n.trim());
if (typeof window.__fuckTimer__ !== 'undefined') return;
const del = function(node) {
if (!node) return;
node.parentNode.removeChild(node);