JavaScript

Notes

Code

1
// Click on buttons in a page
2
// https://twitter.com/brian_lovin/status/1240662440666222597
3
​
4
let buttons = document.getElementsByClassName("unfollow");
5
​
6
for (let [i, v] of [...buttons].entries()) {
7
setTimeout(() => {
8
buttons[i].click();
9
}, i * 500);
10
}
Copied!
1
// Go to specific URL
2
window.location.href = "https://www.google.com";
Copied!
1
// Speed up video playback. Put in console of open page.
2
$("video").playbackRate = 2;
Copied!
1
// click on all the expand buttons on https://github.com/
2
var inputs = document.querySelectorAll("svg[aria-label=Expand]");
3
var buttons = Array.from(inputs).map((e) => e.parentElement.parentElement);
4
buttons.forEach((b) => b.click());
Copied!
1
// start/close PiP video from currently open tab
2
var video = document.querySelectorAll("video")[0];
3
if (
4
video !== undefined &&
5
video.webkitSupportsPresentationMode &&
6
typeof video.webkitSetPresentationMode === "function"
7
) {
8
video.webkitSetPresentationMode(
9
video.webkitPresentationMode === "picture-in-picture"
10
? "inline"
11
: "picture-in-picture"
12
);
13
}
Copied!

Links