librelist archives

« back to archive

[PATCH 1/3] stackexchange.js: Update browser objects according to new format.

[PATCH 1/3] stackexchange.js: Update browser objects according to new format.

From:
Artur Malabarba
Date:
2014-10-22 @ 12:22
Changes "span" to "a".
---
 modules/page-modes/stackexchange.js | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/modules/page-modes/stackexchange.js 
b/modules/page-modes/stackexchange.js
index 222714d..74a2b76 100644
--- a/modules/page-modes/stackexchange.js
+++ b/modules/page-modes/stackexchange.js
@@ -15,13 +15,13 @@
  */
 define_browser_object_class("stackexchange-votes",
     "Browser object class for selecting a vote arrow via hinting.",
-                            
xpath_browser_object_handler('//span[contains(@class,"vote-up-off")]' +
-                                  ' | //span[contains(@class,"vote-down-off")]'),
-     $hint = "select a vote");
+    xpath_browser_object_handler('//a[contains(@class,"vote-up-off")]' +
+                                 ' | //a[contains(@class,"vote-down-off")]'),
+    $hint = "select a vote");
 
 define_browser_object_class("stackexchange-accept-answers",
     "Browser object class for selecting an accepted answer check via hinting.",
-                            
xpath_browser_object_handler('//span[contains(@class,"vote-accepted-off")]'),
+    xpath_browser_object_handler('//a[contains(@class,"vote-accepted-off")]'),
     $hint = "select an accepted answer");
 
 
@@ -45,7 +45,7 @@ interactive("stackexchange-favorite-question",
     "Favorite a question on StackExchange site",
     function (I) {
         var xpr = I.buffer.document.evaluate(
-            '//span[contains(@class,"star-off")]',
+            '//a[contains(@class,"star-off")]',
             I.buffer.document, null,
             Ci.nsIDOMXPathResult.ORCERD_NOTE_ITERATOR_TYPE, null);
         let elem;
-- 
2.1.2

[PATCH 1/3] stackexchange.js: Update browser objects according to new format.

From:
Artur Malabarba
Date:
2014-10-22 @ 14:45
Changes "span" to "a".
---
 modules/page-modes/stackexchange.js | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/modules/page-modes/stackexchange.js 
b/modules/page-modes/stackexchange.js
index 222714d..74a2b76 100644
--- a/modules/page-modes/stackexchange.js
+++ b/modules/page-modes/stackexchange.js
@@ -15,13 +15,13 @@
  */
 define_browser_object_class("stackexchange-votes",
     "Browser object class for selecting a vote arrow via hinting.",
-                            
xpath_browser_object_handler('//span[contains(@class,"vote-up-off")]' +
-                                  ' | //span[contains(@class,"vote-down-off")]'),
-     $hint = "select a vote");
+    xpath_browser_object_handler('//a[contains(@class,"vote-up-off")]' +
+                                 ' | //a[contains(@class,"vote-down-off")]'),
+    $hint = "select a vote");
 
 define_browser_object_class("stackexchange-accept-answers",
     "Browser object class for selecting an accepted answer check via hinting.",
-                            
xpath_browser_object_handler('//span[contains(@class,"vote-accepted-off")]'),
+    xpath_browser_object_handler('//a[contains(@class,"vote-accepted-off")]'),
     $hint = "select an accepted answer");
 
 
@@ -45,7 +45,7 @@ interactive("stackexchange-favorite-question",
     "Favorite a question on StackExchange site",
     function (I) {
         var xpr = I.buffer.document.evaluate(
-            '//span[contains(@class,"star-off")]',
+            '//a[contains(@class,"star-off")]',
             I.buffer.document, null,
             Ci.nsIDOMXPathResult.ORCERD_NOTE_ITERATOR_TYPE, null);
         let elem;
-- 
2.1.2

[PATCH 3/3] stackexchange.js: Exclude "review" and "users" path from URL regexp

From:
Artur Malabarba
Date:
2014-10-22 @ 14:45
None of the mode's features apply to these subpaths, so we exclude them.
Also adds emacs.stackexchange.com site (and others).
---
 modules/page-modes/stackexchange.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/page-modes/stackexchange.js 
b/modules/page-modes/stackexchange.js
index e85e7a4..883ebbf 100644
--- a/modules/page-modes/stackexchange.js
+++ b/modules/page-modes/stackexchange.js
@@ -89,7 +89,7 @@ define_key(stackexchange_keymap, "O", 
"stackexchange-favorite-question");
 ].map(function (x) define_key(stackexchange_keymap, x, null, $fallthrough));
 
 define_keymaps_page_mode("stackexchange-mode",
-    
/^https?:\/\/(?:www.|meta.)?(stackoverflow|serverfault|superuser|stackapps)\.(?:com)\//,
+    
/^https?:\/\/(?:www\.|meta\.)?(stackoverflow|[a-z]+\.stackexchange|serverfault|superuser|stackapps)\.(?:com)\/(?!review|users)/,
     { normal: stackexchange_keymap },
     $display_name = "StackExchange");
 
-- 
2.1.2

[PATCH 2/3] stackexchange.js: Add fallthrough keybinds

From:
Artur Malabarba
Date:
2014-10-22 @ 14:45
Stack exchange now supports keyboard navigation.
Here we add fallthrough keybinds to avoid collision with the site's own keys.
The mode itself is still useful, because the site's key don't cover everything.
---
 modules/page-modes/stackexchange.js | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/modules/page-modes/stackexchange.js 
b/modules/page-modes/stackexchange.js
index 74a2b76..e85e7a4 100644
--- a/modules/page-modes/stackexchange.js
+++ b/modules/page-modes/stackexchange.js
@@ -60,6 +60,34 @@ define_key(stackexchange_keymap, "V", "stackexchange-vote");
 define_key(stackexchange_keymap, "A", "stackexchange-accept-answer");
 define_key(stackexchange_keymap, "O", "stackexchange-favorite-question");
 
+[// Site-wide shortcuts
+    "?",   // Bring up the help dialog
+    "a",   // ask question
+    "b",   // badges
+    "c",   // chat
+    "e",   // edit
+    "f",   // Freshly Updated
+    "g",   // Goto
+    "h",   // home page
+    "i",   // Inbox
+    "j",   // Next
+    "k",   // Previous
+    "l",   // link
+    "m",   // meta site
+    "n",   // unanswered
+    "o",   // Order by
+    "p",   // my profile
+    "q",   // questions
+    "r",   // Recent
+    "s",   // Search
+    "t",   // tags
+    "u",   // First question
+    "v",   // vote...
+    "0", "1", "2", "3", "4",
+    "5", "6", "7", "8", "9",
+    "return"
+].map(function (x) define_key(stackexchange_keymap, x, null, $fallthrough));
+
 define_keymaps_page_mode("stackexchange-mode",
     
/^https?:\/\/(?:www.|meta.)?(stackoverflow|serverfault|superuser|stackapps)\.(?:com)\//,
     { normal: stackexchange_keymap },
-- 
2.1.2

[PATCH 3/3] stackexchange.js: Exclude "review" and "users" path from URL regexp

From:
Artur Malabarba
Date:
2014-10-22 @ 12:22
None of the mode's features apply to these subpaths, so we exclude them.
Also adds emacs.stackexchange.com site (and others).
---
 modules/page-modes/stackexchange.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/page-modes/stackexchange.js 
b/modules/page-modes/stackexchange.js
index e85e7a4..883ebbf 100644
--- a/modules/page-modes/stackexchange.js
+++ b/modules/page-modes/stackexchange.js
@@ -89,7 +89,7 @@ define_key(stackexchange_keymap, "O", 
"stackexchange-favorite-question");
 ].map(function (x) define_key(stackexchange_keymap, x, null, $fallthrough));
 
 define_keymaps_page_mode("stackexchange-mode",
-    
/^https?:\/\/(?:www.|meta.)?(stackoverflow|serverfault|superuser|stackapps)\.(?:com)\//,
+    
/^https?:\/\/(?:www\.|meta\.)?(stackoverflow|[a-z]+\.stackexchange|serverfault|superuser|stackapps)\.(?:com)\/(?!review|users)/,
     { normal: stackexchange_keymap },
     $display_name = "StackExchange");
 
-- 
2.1.2

[PATCH 2/3] stackexchange.js: Add fallthrough keybinds

From:
Artur Malabarba
Date:
2014-10-22 @ 12:22
Stack exchange now supports keyboard navigation.
Here we add fallthrough keybinds to avoid collision with the site's own keys.
The mode itself is still useful, because the site's key don't cover everything.
---
 modules/page-modes/stackexchange.js | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/modules/page-modes/stackexchange.js 
b/modules/page-modes/stackexchange.js
index 74a2b76..e85e7a4 100644
--- a/modules/page-modes/stackexchange.js
+++ b/modules/page-modes/stackexchange.js
@@ -60,6 +60,34 @@ define_key(stackexchange_keymap, "V", "stackexchange-vote");
 define_key(stackexchange_keymap, "A", "stackexchange-accept-answer");
 define_key(stackexchange_keymap, "O", "stackexchange-favorite-question");
 
+[// Site-wide shortcuts
+    "?",   // Bring up the help dialog
+    "a",   // ask question
+    "b",   // badges
+    "c",   // chat
+    "e",   // edit
+    "f",   // Freshly Updated
+    "g",   // Goto
+    "h",   // home page
+    "i",   // Inbox
+    "j",   // Next
+    "k",   // Previous
+    "l",   // link
+    "m",   // meta site
+    "n",   // unanswered
+    "o",   // Order by
+    "p",   // my profile
+    "q",   // questions
+    "r",   // Recent
+    "s",   // Search
+    "t",   // tags
+    "u",   // First question
+    "v",   // vote...
+    "0", "1", "2", "3", "4",
+    "5", "6", "7", "8", "9",
+    "return"
+].map(function (x) define_key(stackexchange_keymap, x, null, $fallthrough));
+
 define_keymaps_page_mode("stackexchange-mode",
     
/^https?:\/\/(?:www.|meta.)?(stackoverflow|serverfault|superuser|stackapps)\.(?:com)\//,
     { normal: stackexchange_keymap },
-- 
2.1.2