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/games/*
  8. // @match *://*.backloggd.com/games/*
  9. // @grant none
  10. // @version 1.0
  11. // @icon https://external-content.duckduckgo.com/ip3/www.backloggd.com.ico
  12. // @license GPLv3
  13. // ==/UserScript==
  14.  
  15. /*
  16. TODO:
  17. - 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
  18. - 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
  19. - add a ProtonDB button if the "released on" section doesn't include Linux
  20. - scrape the IGDB link to add a gog-games.to link if it exists
  21. - SteamRip link? Might be kinda redundant
  22. */
  23.  
  24. // We have to get the game name and the right element from the IGDB link because Backloggd doesn't have any meaningful class names
  25. const link = document.querySelector('a[href^="https://www.igdb.com/games/"]')
  26. const linkElement = link.parentElement
  27.  
  28. if (linkElement) {
  29. let searchURL = getSearchURL(link)
  30. linkElement.innerHTML = `Download on <a href="${searchURL}" target="_blank">cs.rin.ru</a>`
  31. }
  32.  
  33.  
  34. function getSearchURL(link) {
  35. // examle IGDB link: https://backloggd.com/games/yakuza-6-the-song-of-life
  36. let searchQuery = link.href.split('/').pop()
  37. searchQuery = searchQuery.replaceAll('-', ' ')
  38. searchQuery = encodeURIComponent(searchQuery)
  39. 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'
  40. return searchURL
  41. }