mozilla / blurts-addon

Mozilla Public License 2.0
5 stars 8 forks source link

Display actual link HREF instead of "javascript:void(0)" #79

Closed pdehaan closed 6 years ago

pdehaan commented 6 years ago

last_fm___play_music__find_songs__and_discover_artists

Seems to be coming from /src/privileged/blurts/FirefoxMonitor.jsm:

https://github.com/mozilla/blurts-addon/blob/f7cadaa735be547648b191ba05496b7b32495228/src/privileged/blurts/FirefoxMonitor.jsm#L299

I think we can possibly use this as a workaround, where we set the <a href=""> to the str.link, and then make sure we call event.preventDefault() in the click handler.

diff --git a/src/privileged/blurts/FirefoxMonitor.jsm b/src/privileged/blurts/FirefoxMonitor.jsm
index f0dcf7a..a7d9e77 100644
--- a/src/privileged/blurts/FirefoxMonitor.jsm
+++ b/src/privileged/blurts/FirefoxMonitor.jsm
@@ -296,8 +296,9 @@ function makeSpanWithLinks(aStrParts, doc) {
     }
     let anchor = doc.createElementNS(HTML_NS, "a");
     anchor.setAttribute("style", "color: #0060DF");
-    anchor.setAttribute("href", "javascript:void(0)");
+    anchor.setAttribute("href", str.link);
     anchor.addEventListener("click", (event) => {
+      event.preventDefault();
       doc.defaultView.openUILinkIn(str.link, "tab", {});
     });
     anchor.appendChild(doc.createTextNode(str.str));