Skip to content

Instantly share code, notes, and snippets.

View iamandrewluca's full-sized avatar
🚨
Git Inspector

Andrei Luca iamandrewluca

🚨
Git Inspector
View GitHub Profile
@iamandrewluca
iamandrewluca / headings-out-of-order.js
Last active June 29, 2020 17:55
Will outline headings out of order in a page (from https://twitter.com/Una/status/1277652897606635523) #bookmarklet
javascript: void ((function() {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
const styles = document.createTextNode(`
/* Headers out of order (i.e. h2 before h1, etc.) */
/* Result: dotted blue outline */
/* https://twitter.com/Una/status/1277652897606635523 */
h2 ~ h1,
h3 ~ h1,
h4 ~ h1,
h5 ~ h1,
@iamandrewluca
iamandrewluca / bookmarklets.md
Last active October 18, 2023 07:30
Collection of bookmarklets that I use day to day #bookmarklets
@iamandrewluca
iamandrewluca / speak-selected-text.js
Last active September 18, 2022 05:01
Will speak any select text from page #bookmarklet
javascript: void ((async () => {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
let interval = 500;
const intervalId = setInterval(() => {
interval += 500;
if (interval > 5000) { return; }
if (window.speechSynthesis.getVoices().length !== 0) {
clearInterval(intervalId);
@iamandrewluca
iamandrewluca / permissions.ts
Last active November 10, 2021 13:39
permissions based rendering
import { AdminUserRole } from 'gto-patterns'
/**
* A string combined of resource and method separated by a colon `:` e.g. 'user:get'
* Desired to keep resource as a singular word
* Nested resources can be separated by a slash `/` e.g. 'user/account-type:edit'
* A resource can contain one of owned fields separated by `@` e.g. 'user@registrationDate:get'
* Default methods are list, get, create, update, delete (https://cloud.google.com/apis/design/standard_methods)
* Custom methods can be added e.g. block, import, assign, generate
* These rules are invented, if anyone has a better idea how to categorize actions, please suggest.
@iamandrewluca
iamandrewluca / open-localhost.js
Last active April 3, 2023 16:21
Open any URL with origin as localhost:3000 #bookmarklet
javascript: void((function () {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
/**
* Add your own mappers, first found will be used
* @type {{host: string, startsWith: string}[]}
*/
const hostMapper = [
{ startsWith: 'https://example.org', host: 'localhost:3000' },
{ startsWith: 'https://example.org/admin', host: 'localhost:3001' },
];
@iamandrewluca
iamandrewluca / shrug.js
Last active June 18, 2020 16:32
Random Shrug text emoji #bookmarklet
javascript: void(function() {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
const all = [
"¯\\_(ツ)_/¯",
"¯\\(ツ)/¯",
"ʅ(ツ)ʃ",
"乁(ツ)ㄏ",
"乁(ツ)∫",
"ƪ(ツ)∫",
"¯\\_₍ッ₎_/¯",
@iamandrewluca
iamandrewluca / table-flip.js
Last active July 27, 2020 09:30
Random table flip text emoji #bookmarklet
javascript: void(function() {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
const all = [
"(╯°□°)╯︵ ┻━┻",
"(┛◉Д◉)┛彡┻━┻",
"(ノ≧∇≦)ノ ミ ┸━┸",
"(ノಠ益ಠ)ノ彡┻━┻",
"(╯ರ ~ ರ)╯︵ ┻━┻",
"(┛ಸ_ಸ)┛彡┻━┻",
"(ノ´・ω・)ノ ミ ┸━┸",
@iamandrewluca
iamandrewluca / duplicate-id-finder.js
Last active April 6, 2020 21:22
Find and mark elements with on page which have duplicate IDs
javascript: void ((function() {
const ids = document.querySelectorAll('[id]');
Array.from(ids).forEach(el => {
const id = document.querySelectorAll(`[id="${el.id}"]`);
if (id.length > 1 && id[0] === el) {
console.log('Duplicate id ' + el.id);
Array.from(id).forEach(fel => {
fel.style.outline = '5px solid red';
});
alert('duplicate found');
@iamandrewluca
iamandrewluca / request-picture-in-picture.js
Last active April 25, 2024 13:46
Request picture in picture on first found video that is playing #bookmarklet
javascript: void ((function() {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
/** @type {NodeListOf<HTMLIFrameElement>} */
const iFrames = window.document.querySelectorAll('iframe');
console.log(`Found ${iFrames.length} iframes`);
/** @type {Document[]} */
const allDocuments = [
window.document,
@iamandrewluca
iamandrewluca / password-toggler.js
Last active June 18, 2020 16:32
Toggle password inputs to text back and forth #bookmarklet
javascript: void ((function() {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
const passwordInputs = document.querySelectorAll('[type="password"], [data-password-bookmark-toggled]');
Array.from(passwordInputs).forEach(e => {
if (e.getAttribute('data-password-bookmark-toggled')) {
e.removeAttribute('data-password-bookmark-toggled');
e.setAttribute('type', 'password');
} else {
e.setAttribute('data-password-bookmark-toggled', true);
e.setAttribute('type', 'text');