cs.rin.ru quick search all terms

add a field beside the search button to search all terms and an option to search within posts https://cs.rin.ru/forum/viewtopic.php?f=14&t=134386

  1. // ==UserScript==
  2. // @name cs.rin.ru quick search all terms
  3. // @namespace none
  4. // @version 1
  5. // @description add a field beside the search button to search all terms and an option to search within posts https://cs.rin.ru/forum/viewtopic.php?f=14&t=134386
  6. // @author odusi
  7. // @match https://cs.rin.ru/forum/*
  8. // @icon none
  9. // @grant none
  10. // ==/UserScript==
  11. /*
  12. Search within
  13. all = Post subjects and message text. msgonly = Message text only. titleonly = Topic titles only. topics = First post of topics only
  14. */
  15. let sf = 'titleonly'
  16. /*
  17. Sort results by
  18. a = author. t = post time. f = forum. i = topic title. s = post subject
  19. */
  20. const sk = 't'
  21. const sd = 'd' // Sort results by: a = ascending. d = descending
  22. const sr = 'topics' // Display results as: topics, posts
  23. const ch = 300; // Return first # characters of posts
  24.  
  25. document.querySelector("#menubar > table:nth-child(3) > tbody > tr > td:nth-child(2)").insertAdjacentHTML('afterbegin', `
  26. <div id="search-all-terms" style="position:relative;display:inline-block;"><input type="text" placeholder="Search for all terms">
  27. <div style="position: absolute; top: 110%">
  28. <input id="somecheckbox" type="checkbox" style="margin-right: 0.3rem;">
  29. <label for="somecheckbox">Search within posts</label></div>
  30. </div></div>
  31. `)
  32.  
  33. const container = document.getElementById("search-all-terms")
  34. const inputField = container.querySelector('input')
  35. const checkbox = container.querySelector('#somecheckbox')
  36.  
  37. inputField.addEventListener('keydown', ev => {
  38. if (ev.code === 'Enter') {
  39. if (checkbox.checked) sf = 'all'
  40. window.location.href = `./search.php?keywords=${encodeURIComponent(inputField.value).replace(/%20/g, "+")}&terms=all&author=&sc=1&sf=${sf}&sk=${sk}&sd=${sd}&sr=${sr}&st=0&ch=${ch}&t=0`
  41. }
  42. })

QingJ © 2025

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