Skip to content

Instantly share code, notes, and snippets.

@kbauer
kbauer / Adblock Simple.js
Last active April 27, 2024 05:17
A simple adblocker bookmarklet, removing suspicious iframes. To install, copy-paste the source to a bookmark (will automatically remove newline characters). Extend the array ``exceptOrigins`` in order to create new exceptions. Careful: If bookmarklets get too long, they might stop working. This methods provides on-demand adblocking (as opposed t…
javascript:/* Adblock Simple */
(function(){
const exceptOrigins = [
'https://disqus.com',
document.origin
];
function remIF(e){
try{
var orgn = new URL(e.src || 'http://unknown-src').origin;
@kbauer
kbauer / unicode.ahk
Created June 20, 2017 11:30
Autohotkey-script for converting LaTeX-like input to unicode characters. "Ctrl+Alt+Shift+U" toggles it on and off.
;; -*- mode: text; coding: utf-8 -*-
;;
;; DO NOT EDIT MANUALLY!
;;
;; FILE IS GENERATED BY EMACS LISP SCRIPT
;; `%((file-name-nondirectory qta-ahkdata:generator-script-file)%)'
;;
;;
;; Writing LaTeX glyphs with
;; AutoHotKey (unicode versions only)
javascript:/* MailToSelf */ (function(){target = "mailto:my.name@example.com?subject=" + encodeURIComponent(document.title) + "&body=" + encodeURIComponent(location.href); location.href = target;})()

On mobile devices, I often use "mail-to-self" type apps to quickly send me a webpage for later reading; Funnelling everything into my mailbox is simply the only way I will actually look at it again. On mobile, these apps integrate with the OS-provided "Share" menus, but on the desktop I had to manually write an email. Hence this bookmarklet, to automate creation of the reminder Email.

Installation

  1. Create a new bookmark.
javascript: body.document.requestFullscreen(); undefined
// Bookmarklet, that allows triggering fullscreen mode in mobile browser/website combinations,
// that don't give the option explicitly. Useful when using webapps on mobile,
// e.g. Teams, lesen.amazon.de (read.amazon.com), ...
//
// Useless on desktop browsers, where the F11 key usually triggers full-screen.
//
// Does not work on iOS, because the iOS javascript engines do not implement any fullscreen API.
// Instead, a more limited
@kbauer
kbauer / myjs-compile-bookmarklet.el
Last active September 21, 2023 07:53
Emacs-lisp command for compiling a javascript file into a bookmarklet, by stripping unnecessary characters and adding a wrapper.
;;; myjs-compile-bookmarklet.el --- strip javascript code as bookmarklet -*- lexical-binding: t; coding: utf-8; lisp-indent-offset: nil; -*-
;; Copyright (C) 2018 Klaus-Dieter Bauer
;; Author: Klaus-Dieter Bauer <kdb.devel@gmail.com>
;; Keywords: javascript, bookmarklet
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or

Reader Mode.js

Add as bookmarklet (see below):

javascript:/* Reader Mode.js /(function(){ const IFWL=['gfycat.com','disqus.com','www.youtube.com',location.host,];const ifbl=new RegExp('derstandard\.at\/AdServer\/');const startupTasks=[disableViewport,];const periodicTasks=[disableStaticFloaters,removeIframes,];function disableStaticFloaters(){for(let e of document.getElementsByTagName('')){if(window.getComputedStyle(e).position.startsWith('fixed')){e.style.setProperty('position','static','important');}}}function removeIframes(){const iframes=getAllIframesRecursively();for(const e of getAllIframesRecursively().reverse()){try{const doRemove=(!e.src)? false : IFWL.indexOf(new URL(e.src).host)==-1 ? true : e.src.match(ifbl)? true : false;if(doRemove&&e.parentElement){e.parentElement.removeChild(e);}}catch(err){reportError(err,['FAILED TO REMOVE IFRAME',e]);}}window.readerModeRemainingIframes=getAllIframesRecursively();}function disableViewport(){const vp=document.querySelector('meta[name=v

@kbauer
kbauer / boogie-board-daemon
Last active August 28, 2022 16:02
A companion script for the BoogieBoard Sync 9.7 eWriter. The main purpose is to put the latest Bluetooth-synced page into the clipboard as image data. Depends on the `imagemagick-scan-to-mono.sh` script (see https://gist.github.com/kbauer/e5bd0dc12142e7a6c97f).
#!/usr/bin/env bash
source libstacktrace || true
set -e -E -u
BOOGIEDIR="$(cygpath "$LOCALAPPDATA")/BoogieBoardSync/Downloads"
cd "$BOOGIEDIR"
MANUAL="
@kbauer
kbauer / imagemagick-scan-to-mono.sh
Last active May 31, 2021 17:26
A tool for converting scanned or photographed pages into a fax-style bi-level png with minimal storage use. Also removes background color gradients. See also my other gist `imagemagick-scan-pdf-to-mono.sh`
#!/usr/bin/env bash
# -*- mode: sh; coding: us-ascii-unix -*-
source libstacktrace || true
set -e -u -E
MANUAL="
Usage: $0 INFILE OUTFILE [BLURRADIUS;default:20px]
Takes a document scan INFILE (an image) and produces a monochromatized
! writerec.f90
program main
implicit none
print '(*(1x,G0))', 'x', getX(), 'x', getX()
contains
integer function getX()
getX = 1
print *, '(inside getX)'
end function getX
<html>
<head><title>Hello world.</title></head>
<body><h1>Bye world.</h1></body>
</html>