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. // @grant none
  10. // @version 1.2
  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.  
  26. function changeIgdbUrl () {
  27. const link = document.querySelector('a[href^="https://www.igdb.com/games/"]')
  28. const linkElement = link.parentElement
  29.  
  30. if (linkElement) {
  31. let searchURL = getSearchUrl(link)
  32. linkElement.innerHTML = `Download on <a href="${searchURL}" target="_blank">cs.rin.ru</a>`
  33. }
  34. }
  35.  
  36.  
  37. function getSearchUrl(link) {
  38. // examle IGDB link: https://backloggd.com/games/yakuza-6-the-song-of-life
  39. let searchQuery = link.href.split('/').pop()
  40. searchQuery = searchQuery.replaceAll('-', ' ')
  41. searchQuery = encodeURIComponent(searchQuery)
  42. 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'
  43. return searchURL
  44. }
  45.  
  46. // Backloggd uses those weird SPA style links, so we have to re-run each time the url changes
  47. // Will occasionally decide to not work. Refresh fixes this but might be worth migrating to vm-url in case that works better
  48. // https://violentmonkey.github.io/api/matching/#matching-spa-sites-like-fb-github-twitter-youtube
  49.  
  50. onUrlChange();
  51.  
  52. if (self.navigation) {
  53. navigation.addEventListener('navigatesuccess', onUrlChange);
  54. } else {
  55. let u = location.href;
  56. new MutationObserver(() => u !== (u = location.href) && onUrlChange())
  57. .observe(document, {subtree: true, childList: true});
  58. }
  59.  
  60. function onUrlChange() {
  61. changeIgdbUrl()
  62. }