Skip to content

Instantly share code, notes, and snippets.

@luetage
Last active October 28, 2024 18:36
Show Gist options
  • Save luetage/6a66af73a4dd264fcb05fe24926b2e36 to your computer and use it in GitHub Desktop.
Save luetage/6a66af73a4dd264fcb05fe24926b2e36 to your computer and use it in GitHub Desktop.
Collection of bookmarklets for Vivaldi browser command chains. Development version. Get the full recipes here ☛ https://forum.vivaldi.net/post/500553
// Automatic Line Wrap
// Automatically switch on wrapping lines in page source.
javascript: (() => {
document.querySelector("input").click();
history.replaceState({}, "", location.href);
})();
// Embed Youtube
// Takes the current video and opens it embed.
javascript: (() => {
const url = new URL(window.location.href);
window.open(`${url.origin}/embed/${url.search.split("=")[1]}`, "_self");
})();
// Reverse Image Search
// Retrieves the image source under the mouse cursor, adds it to the page and
// selects it.
javascript: (() => {
function i(e) {
if (e.target.tagName === "IMG") {
document.removeEventListener("mousemove", i);
let u = e.target.getAttribute("src");
if (u) {
const a = document.createElement("a");
if (u.startsWith("..")) {
u = window.location.origin + u.slice(2);
}
a.innerText = u;
console.info(`reverse image search ${u}`);
a.style.opacity = "0";
a.style.fontSize = "0em";
document.body.appendChild(a);
const r = document.createRange();
r.selectNodeContents(a);
window.getSelection().addRange(r);
}
}
}
window.getSelection().removeAllRanges();
document.addEventListener("mousemove", i);
setTimeout(() => document.removeEventListener("mousemove", i), 1900);
history.replaceState({}, "", location.href);
})();
// Tab Scroll
// Scrolls to top of page and back to initial position.
javascript: (() => {
let offset = window.scrollY;
if (offset > 0) {
window.sessionStorage.setItem("offset", offset);
window.scrollTo({ top: 0, behavior: "instant" });
} else {
window.scrollTo({
top: window.sessionStorage.getItem("offset") || 0,
behavior: "instant",
});
}
history.replaceState({}, "", location.href);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment