fork download
  1. // ==UserScript==
  2. // @name SMF - get quote markup
  3. // @author zarg
  4. // @include http://*/forum/index.php?topic=*
  5. // @match http://*/forum/index.php?topic=*
  6. // @version 1.0
  7. // ==/UserScript==
  8.  
  9.  
  10. function addJQuery(callback) {
  11. var script = document.createElement("script");
  12. script.setAttribute("src",
  13. "http://a...content-available-to-author-only...s.com/ajax/libs/jquery/1/jquery.min.js");
  14. script.addEventListener('load', function() {
  15. var script = document.createElement("script");
  16. script.textContent = "(" + callback.toString() + ")();";
  17. document.body.appendChild(script);
  18. }, false);
  19. document.body.appendChild(script);
  20. }
  21.  
  22.  
  23. addJQuery(function() {
  24. var topicid = window.location.href.match(/topic=([^.]+)/)[1];
  25. var idPattern = /subject_(.*)/;
  26. $("h5[id^=subject_]").each(function(i, postHeader) {
  27. var messageid = $(postHeader).attr("id").match(idPattern)[1];
  28. var poster = $(postHeader).parents(".post_wrapper").find(".poster > h4")
  29. .text().replace(/^\s+|\s+$/g, "");
  30. $(postHeader).after(
  31. $("<a />", {
  32. href: "javascript:void(0)", text: "Get quote markup",
  33. click: function() {
  34. var messageText = "";
  35. $(postHeader).parents(".postarea").find("[id^=msg_]")
  36. .contents().not(".quoteheader, blockquote")
  37. .each(function() {
  38. if (this.nodeName.toLowerCase() == "br") {
  39. messageText += "\n";
  40. } else {
  41. messageText += $(this).text();
  42. }
  43. });
  44.  
  45. $(this).after(
  46. $("<textarea />", {
  47. css: {display: "block"},
  48. width: 700, height: 50,
  49. text: "[quote author=" + poster
  50. + " link=topic=" + topicid
  51. + ".msg" + messageid + "#msg" + messageid
  52. + " date=1356076800]"
  53. + messageText + "[/quote]"
  54. }));
  55. }
  56. }));
  57. });
  58. });
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty