|
|
|
|
|
by jasomill
1216 days ago
|
|
Safari, not Chrome, but here's an AppleScript I use to map a trackpad gesture to the "next page" link on a wide variety of Web sites, tell application "Safari" to do JavaScript "
(() => {
const loc = Array
.from(document.querySelectorAll('[rel=\"next\"], .next, [title=\"Next page\"]'))
.map(i => i.getAttribute('href')).filter(i => i)[0];
if (loc) {
document.location = loc;
}
})()
" in document 1
s/next/prev/g s/Next/Previous/ for the matching "previous page" script.Note that this requires Safari's "AllowJavaScriptFromAppleEvents" preference to be set, either via a "Develop" menu option or directly in its preferences file via, e.g., the defaults write com.apple.Safari AllowJavaScriptFromAppleEvents -bool TRUE
shell command, and that this setting allows any program you authorize[1] to send Apple Events to Safari to potentially do Terrible Things. Given that the setting is both disabled and hidden by default, and additionally gated by an opt-in privacy preference, it's presumably an unlikely target for garden-variety malware, however.[1] Check the Automation group in the Privacy tab of the Security & Privacy preference pane for a list of programs so authorized. |
|