Skip to content

Instantly share code, notes, and snippets.

@refparo
refparo / copy_canvas.js
Last active October 10, 2024 18:35
Copy canvas to clipboard
// 1. Save this to a bookmarklet with https://make-bookmarklets.com/
// 2. Run bookmarklet
// 3. Find the canvas in developer tool and "use it in console"
// 4. Run `copyCanvas(temp0)`
// 5. Click anywhere on the webpage (to workaround the restriction that
// clipboard writes must be triggered some user interaction)
window.copyCanvas = canvas => (
canvas.toBlob(blob => (
window.addEventListener("click", () => (
navigator.clipboard.write([
@refparo
refparo / feedbro_save_infinite_entries.js
Last active October 10, 2024 18:27
Make Feedbro save unlimited number of feed entries
function setFeedMaxEntries(count = Number.MAX_SAFE_INTEGER) {
let f = chrome.extension.getBackgroundPage().feedbrobg
f.getSettings().setFeedMaxEntries(count)
f.saveSettings()
}
setFeedMaxEntries(Number.MAX_SAFE_INTEGER)
import fs from "fs/promises";
const file = await fs.readFile("metadata.json", { encoding: "utf-8" });
/** @type {{ [key: string]: { source: string } }} */
const metadata = JSON.parse(file);
/** @type {{ [key: string]: number }} */
const authors = {};
Object.values(metadata).forEach((data) => {
// fig: the <figure> element to download
// could be easily used in batch download
// requires CORS errors to be disabled
const dlPhoto = async (fig) => {
const img = fig.querySelector('u > a').href
const res = await (await fetch(img)).text()
const doc = new DOMParser().parseFromString(res, 'text/html')
const photo = doc.querySelector('#submissionImg').src
const blob = await (await fetch(photo)).blob()
const a = document.createElement('a')