🏠 返回首頁 

Greasy Fork is available in English.

Steam Link Language Checker

Check if Steam game supports Chinese and mark the link with 🀄 if it does


安装此脚本?
  1. // ==UserScript==
  2. // @name Steam Link Language Checker
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Check if Steam game supports Chinese and mark the link with 🀄 if it does
  6. // @author 冰雪聪明琪露诺
  7. // @match https://store.steampowered.com/wishlist*
  8. // @license MIT
  9. // ==/UserScript==
  10. (function() {
  11. 'use strict';
  12. // Function to get appid from Steam URL
  13. function getAppId(url) {
  14. const match = url.match(/\/app\/(\d+)/);
  15. return match ? match[1] : null;
  16. }
  17. // Function to check if the game supports Chinese
  18. async function checkChines###pport(appId) {
  19. const apiUrl = `https://store.steampowered.com/api/appdetails/?appids=${appId}&l=schinese`;
  20. try {
  21. const response = await fetch(apiUrl);
  22. const data = await response.json();
  23. const appData = data[appId].data;
  24. if (appData && appData.supported_languages) {
  25. const supportedLanguages = appData.supported_languages;
  26. if (supportedLanguages.includes('简体中文') || supportedLanguages.includes('繁体中文')) {
  27. return true;
  28. }
  29. }
  30. } catch (error) {
  31. console.error('Error fetching data:', error);
  32. }
  33. return false;
  34. }
  35. // Function to process all Steam links on the page
  36. async function processLinks() {
  37. const links = document.querySelectorAll('a[href*="store.steampowered.com/app/"]');
  38. const processedAppIds = new Set();
  39. for (const link of links) {
  40. const appId = getAppId(link.href);
  41. if (appId && !processedAppIds.has(appId)) {
  42. processedAppIds.add(appId);
  43. const supportsChinese = await checkChines###pport(appId);
  44. if (supportsChinese) {
  45. link.insertAdjacentHTML('beforebegin', '🀄 ');
  46. }
  47. await new Promise(resolve => setTimeout(resolve, 1000)); // Wait 1 second between API requests
  48. }
  49. }
  50. }
  51. // Store processed links to avoid duplicate checks
  52. const processedLinks = new WeakSet();
  53. // Function to process newly added links
  54. async function processNewLinks() {
  55. const links = document.querySelectorAll('a[href*="store.steampowered.com/app/"]');
  56. for (const link of links) {
  57. if (!processedLinks.has(link)) {
  58. processedLinks.add(link);
  59. const appId = getAppId(link.href);
  60. if (appId) {
  61. const supportsChinese = await checkChines###pport(appId);
  62. if (supportsChinese) {
  63. link.insertAdjacentHTML('beforebegin', '🀄 ');
  64. }
  65. await new Promise(resolve => setTimeout(resolve, 1000)); // Wait 1 second between API requests
  66. }
  67. }
  68. }
  69. }
  70. // Process links when the page is loaded
  71. window.addEventListener('load', processNewLinks);
  72. // Observer to watch for new links added to the page
  73. const observer = new MutationObserver(processNewLinks);
  74. observer.observe(document.body, { childList: true, subtree: true });
  75. })();