Add initial support for `p' and `n' accesskey-s - dotfiles - leot's dotfiles
(HTM) hg clone https://bitbucket.org/iamleot/dotfiles
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) changeset a2fb8faba7197b4384cc919a04d567b564bdabb0
(DIR) parent 62f0bb6261a98b0a3a3b570c9699fbb72c3fe270
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Sun, 9 Jun 2019 12:55:45
Add initial support for `p' and `n' accesskey-s
Still a prototype and works only based on selectors...
Maybe reversed document.links should be used instead and also the
`.text' of each link honored to permit selection based on text of
the anchors too.
Diffstat:
surf/script/default.js | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
---
diff -r 62f0bb6261a9 -r a2fb8faba719 surf/script/default.js
--- a/surf/script/default.js Sat Jun 08 21:24:12 2019 +0200
+++ b/surf/script/default.js Sun Jun 09 12:55:45 2019 +0200
@@ -16,3 +16,36 @@
});
})();
+
+/*
+ * Add `p' and `n' accesskey-s (previous/next via `Mod1 + p'/`Mod1 + n')
+ */
+(function() {
+
+ previous_selectors = [
+ 'a[rel="prev"]',
+ 'a[aria-label="Pagina precedente"]', // google.it
+ 'a[aria-label="Previous page"]', // google.com
+ ];
+
+ next_selectors = [
+ 'a[rel="next"]',
+ 'a[aria-label="Pagina successiva"]', // google.it
+ 'a[aria-label="Next page"]', // google.com
+ ];
+
+ for (p of previous_selectors) {
+ if (e = document.querySelector(p)) {
+ e.accessKey = "p";
+ break;
+ }
+ }
+
+ for (n of next_selectors) {
+ if (e = document.querySelector(n)) {
+ e.accessKey = "n";
+ break;
+ }
+ }
+
+})();