https://github.com/teles/bookmarklets
A list of useful bookmarklets for daily usage
https://github.com/teles/bookmarklets
Last synced: 4 months ago
JSON representation
A list of useful bookmarklets for daily usage
- Host: GitHub
- URL: https://github.com/teles/bookmarklets
- Owner: teles
- Created: 2023-01-10T19:52:58.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-07T14:30:14.000Z (over 3 years ago)
- Last Synced: 2025-02-17T21:06:38.383Z (over 1 year ago)
- Size: 6.84 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bookmarklets
A list of useful bookmarklets for daily usage
## General
### Prepend relative URLs with base URL
```JavaScript
const prependURL = window.prompt("Base URL to prepend", location.hostname)
Array.from(document.querySelectorAll("a[href]")).filter(a => {
return a.getAttribute("href") !== a.href;
}).forEach((a, index, anchors ) => {
a.setAttribute("href", [
prependURL.replace(/\/$/, ''),
a.getAttribute("href").replace(/^\//, '')
].join("/"));
if(index === anchors.length -1) {
window.alert(`Success: ${anchors.length} changed anchors`)
}
})
```
### Show images without alt attribute
```JavaScript
const borderColor = window.prompt("Set a highlight color for images without alt", "red");
const imgs = Array.from(document.querySelectorAll("img:not([src])"));
imgs.forEach(img => img.style.border = `3px dashed ${borderColor}`);
window.alert(`This page has ${imgs.length || 0} images without alt attribute`);
```
### Fill in all inputs with their placeholder values
```JavaScript
document.querySelectorAll('input[placeholder]').forEach(input => input.value = input.placeholder);
```
### Fill in all inputs with placeholders plus timestamp
```JavaScript
const inputReplacers = {
"email": (value) => value.replace(/(.*?)@(.*?)/, `$1+${new Date().getTime()}@$2`),
"text": (value) => `${value} +${new Date().getTime()}`
}
document.querySelectorAll('input[placeholder]').forEach(input => {
input.value = inputReplacers[input.type] ? inputReplacers[input.type](input.placeholder) : input.placeholder;
});
```