Greasy Fork 支持简体中文。

Replace IGDB with cs.rin.ru for Backloggd

Replaces the IGDB button on Backloggd with a cs.rin.ru downolad link

目前為 2025-03-10 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Replace IGDB with cs.rin.ru for Backloggd
  3. // @description Replaces the IGDB button on Backloggd with a cs.rin.ru downolad link
  4. // @author Soap
  5. // @namespace soap.systems
  6. // @homepageURL https://soap.systems
  7. // @match *://backloggd.com/*
  8. // @match *://*.backloggd.com/*
  9. // @match *://cs.rin.ru/forum/search.php*
  10. // @grant none
  11. // @version 1.3
  12. // @icon https://external-content.duckduckgo.com/ip3/www.backloggd.com.ico
  13. // @license GPLv3
  14. // ==/UserScript==
  15.  
  16. /*
  17. TODO:
  18. - currently the script takes you to the search results. update it to check the results page, and if there's only one match result, open it automatically
  19. - maybe i could add a url parameter to the links opened by the script to make sure it doesn't interfere with normal use of the site
  20. - add a ProtonDB button if the "released on" section doesn't include Linux
  21. - scrape the IGDB link to add a gog-games.to link if it exists
  22. - SteamRip link? Might be kinda redundant
  23. */
  24.  
  25. // We have to get the game name and the right element from the IGDB link because Backloggd doesn't have any meaningful class names
  26.  
  27. function changeIgdbUrl () {
  28. if (location.host == "backloggd.com") {
  29. const link = document.querySelector('a[href^="https://www.igdb.com/games/"]')
  30. const linkElement = link.parentElement
  31.  
  32. if (linkElement) {
  33. let searchURL = getSearchUrl(link)
  34. linkElement.innerHTML = `Download on <a href="${searchURL}" target="_blank">cs.rin.ru</a>`
  35. }
  36. }
  37. }
  38.  
  39.  
  40. function getSearchUrl(link) {
  41. // examle IGDB link: https://backloggd.com/games/yakuza-6-the-song-of-life
  42. let searchQuery = link.href.split('/').pop()
  43. searchQuery = searchQuery.replaceAll('-', ' ')
  44. searchQuery = encodeURIComponent(searchQuery)
  45. let searchURL = 'https://cs.rin.ru/forum/search.php?keywords=' + searchQuery + '&terms=all&author=&sc=1&sf=titleonly&sk=t&sd=d&sr=topics&st=0&ch=300&t=0&submit=Search&backloggdrinscript=true'
  46. return searchURL
  47. }
  48.  
  49. function clickFirstRinLink() {
  50. let params = new URLSearchParams(document.location.search)
  51. // There's a 'backloggdrinscript' parameter added to the end of the search URL so we can detect you got to the search page from the script
  52. let scriptActive = params.get('backloggdrinscript');
  53. if (scriptActive) {
  54. const topics = document.querySelectorAll('a.topictitle');
  55.  
  56. // only redirect if there's one link in the search results
  57. if (topics.length === 1) {
  58. window.location.href = topics[0].href;
  59. }
  60. }
  61. }
  62.  
  63. clickFirstRinLink()
  64.  
  65.  
  66. // Backloggd uses those weird SPA style links, so we have to re-run each time the url changes
  67. // Will occasionally decide to not work. Refreshing fixes this but might be worth migrating to vm-url in case that works better
  68. // https://violentmonkey.github.io/api/matching/#matching-spa-sites-like-fb-github-twitter-youtube
  69. onUrlChange()
  70.  
  71. if (self.navigation) {
  72. navigation.addEventListener('navigatesuccess', onUrlChange);
  73. } else {
  74. let u = location.href;
  75. new MutationObserver(() => u !== (u = location.href) && onUrlChange())
  76. .observe(document, {subtree: true, childList: true});
  77. }
  78.  
  79. function onUrlChange() {
  80. changeIgdbUrl()
  81. }