Index: common.js |
=================================================================== |
--- a/common.js |
+++ b/common.js |
@@ -33,6 +33,31 @@ |
}, callback); |
} |
+function setLinks(id, ...args) |
+ { |
+ let element = E(id); |
+ if (!element) |
+ { |
+ return; |
+ } |
+ |
+ let links = element.getElementsByTagName("a"); |
+ |
+ for (let i = 0; i < links.length; i++) |
+ { |
+ if (typeof args[i] == "string") |
+ { |
+ links[i].href = args[i]; |
+ links[i].setAttribute("target", "_blank"); |
+ } |
+ else if (typeof args[i] == "function") |
+ { |
+ links[i].href = "javascript:void(0);"; |
+ links[i].addEventListener("click", args[i], false); |
+ } |
+ } |
+ } |
+ |
function checkShareResource(url, callback) |
{ |
ext.backgroundPage.sendMessage({ |