Guest User

Untitled

a guest
Apr 24th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. (function() {
  2.  
  3. function st(a) {
  4. return a.replace(/<[^>]*>/, '');
  5. }
  6.  
  7. CmdUtils.CreateCommand({
  8. names: ["click", "click link", "c"],
  9. description: "Clicks a link.",
  10. author: {name: "SHiNKiROU"},
  11. license: "GPL",
  12. arguments: [{role: 'object', nountype: noun_arb_text}],
  13. preview: function preview(pblock, args) {
  14. pblock.innerHTML = ((args.object.text) ? _("List of links of ") + " <b>" + args.object.html + "</b>:" : '') + "<ul>";
  15. var doc = CmdUtils.getDocument();
  16. jQuery("a", doc).each(function(i, link) {
  17. link = jQuery(link);
  18. if (st(link.html()).match(args.object.text)) {
  19. pblock.innerHTML += "<li><b>" + st(link.html()) + "</b> : " + link.attr("href") + "</li>";
  20. }
  21. });
  22. pblock.innerHTML += "</ul>";
  23. },
  24. execute: function execute(args) {
  25. var doc = CmdUtils.getDocument();
  26. jQuery("a", doc).each(function(i, link) {
  27. link = jQuery(link);
  28. if (st(link.html()).match(args.object.text)) {
  29. CmdUtils.getWindow().location = link.attr("href");
  30. }
  31. });
  32. }
  33. });
  34.  
  35. })();
Add Comment
Please, Sign In to add comment