Hack Forums - Multi Quote

Adds a multiquote button to the post management buttons.

  1. // ==UserScript==
  2. // @name Hack Forums - Multi Quote
  3. // @namespace Doctor Blue
  4. // @description Adds a multiquote button to the post management buttons.
  5. // @include *hackforums.net/showthread.php?tid=*
  6. // @require https://cdn.jsdelivr.net/jquery/1.10.2/jquery-1.10.2.min.js
  7. // @require https://cdn.jsdelivr.net/jquery.cookie/1.4.1/jquery.cookie.min.js
  8. // @version 0.2.2
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. // Prevent conflicts with other userscripts
  13. var $j = $.noConflict(true)
  14.  
  15. // Add the button to post management buttons
  16. var $posts = $j('table[id*="post_"] .bitButton:contains("Quote")')
  17. .after(' <a class="bitButton multiquote" href="javascript:void(0)">Quote+</a>')
  18.  
  19. // Restyle the multiquote insert message
  20. $j('#quickreply_multiquote')
  21. .css('background-color', '#777777')
  22. .css('border', '1px #CCCCCC dashed')
  23.  
  24. // Parse the multiquote cookie
  25. function getQuotes() {
  26. var quotes = $j.cookie('multiquote')
  27. return (quotes === undefined ? new Array() : quotes.split('|'))
  28. }
  29.  
  30. // Change button text to Q- if post is already being quoted on load
  31. function quoteInit() {
  32. var quotes = getQuotes()
  33. $j('.multiquote').text('Quote+')
  34. quotes.forEach(function(pid) {
  35. $j('#post_' + pid + ' .multiquote').text('Quote-')
  36. })
  37. }
  38.  
  39. // Retrieve the quoted content
  40. function fetchQuoteText() {
  41. Thread.spinner = new ActivityIndicator("body", {image: imagepath + "/spinner_big.gif"})
  42. $j.get('/xmlhttp.php?action=get_multiquoted&load_all=1', function(data) {
  43. console.log("Inserting text")
  44. var olddata = $j('#message').val()
  45. $j('#message').val(olddata + data)
  46. Thread.spinner.destroy()
  47. Thread.spinner = ""
  48. clearQuotes()
  49. })
  50. }
  51.  
  52. function clearQuotes() {
  53. $j.removeCookie('multiquote', {path: '/', domain: '.hackforums.net'})
  54. $j('#quickreply_multiquote').hide()
  55. quoteInit()
  56. }
  57.  
  58. // Set all buttons to Q+ after inserting
  59. $j('#quickreply_multiquote > span > a[href*="load_all_quotes"]')
  60. .prop('onclick', null).off('click') // Remove MyBB handler
  61.  
  62. $j('#quickreply_multiquote > span > a[href*="load_all_quotes"]').on('click', function(event) {
  63. console.log("Inserting quotes")
  64. $j('.bitButton.multiquote').text('Quote+')
  65. fetchQuoteText()
  66. event.preventDefault()
  67. })
  68.  
  69. $j('.bitButton.multiquote').on('click', function(event) {
  70. // Get the post id (Dunno why parentsUntil doesn't work here)
  71. var pid = $j(this).parent().parent().parent().parent().parent().attr('id').substr(5)
  72. var quotes = getQuotes()
  73. // Remove the quote if it's already there, add it if it isn't
  74. var i = $j.inArray(pid, quotes)
  75. if(i !== -1) { // Remove quote if found
  76. quotes.splice(i, 1)
  77. $j(this).text("Quote+")
  78. } else { // Add quote if not found
  79. quotes.push(pid)
  80. $j(this).text("Quote-")
  81. }
  82.  
  83. // Update the cookie
  84. if(quotes.length > 0) {
  85. $j('#quickreply_multiquote').show()
  86. $j.cookie('multiquote', quotes.join('|'), {expires: 365, path: '/', domain: '.hackforums.net'})
  87. } else {
  88. $j('#quickreply_multiquote').hide()
  89. $j.removeCookie('multiquote', {path: '/', domain: '.hackforums.net'})
  90. }
  91. })

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址