您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Enhances GOG game pages with data from VNDB.
当前为
// ==UserScript== // @name VNDB GOG Enhancer // @namespace https://vndb.org/ // @version 1.0 // @description Enhances GOG game pages with data from VNDB. // @author darklinkpower // @match https://www.gog.com/*/game/* // @icon https://www.google.com/s2/favicons?sz=64&domain=gog.com // @grant GM_xmlhttpRequest // @connect api.vndb.org // @run-at document-end // @license MIT // ==/UserScript== (function() { 'use strict'; const LENGTH_MAP = { 1: "Very short", 2: "Short", 3: "Medium", 4: "Long", 5: "Very long" }; function formatMinutes(minutes) { if (minutes < 60) { return "" + minutes + "m"; } return "" + Math.floor(minutes / 60) + "h" + (minutes % 60) + "m"; } var CurrentAppID; function GetAppIDFromUrl() { var currentURL = window.location.href; var idPattern = /\/game\/([^\/?#]+)/; var match = currentURL.match(idPattern); if (match && match.length > 1) { return match[1]; } else { console.log("Id not found from url"); return null; } } function GetCurrentAppID() { if( !CurrentAppID ) { CurrentAppID = GetAppIDFromUrl(); } return CurrentAppID; } function makeRow(rowClass, categoryText, contentText, contentUrl) { const row = document.createElement("div"); row.className = "table__row details__row " + rowClass; const category = document.createElement("div"); category.className = "details__category table__row-label"; category.textContent = categoryText; const content = document.createElement("div"); content.className = "details__content table__row-content"; if (contentUrl) { const contentEl = document.createElement("a"); contentEl.className = "details__link"; contentEl.textContent = contentText; contentEl.href = contentUrl; content.appendChild(contentEl); } else { content.textContent = contentText; } row.appendChild(category); row.appendChild(content); return row; } let appId = GetCurrentAppID(); if (appId == null) { return; } GM_xmlhttpRequest({ method: "POST", url: "https://api.vndb.org/kana/vn", data: JSON.stringify({ "filters": ["release", "=", ["extlink", "=", ["gog", appId]]], "fields": "length,length_votes,length_minutes,rating,votecount" }), headers: { "Content-Type": "application/json" }, onload: function(response) { let result = JSON.parse(response.responseText); if (!result.results || result.results.length == 0) { return; } let item = result.results[0]; const vndbIdRow = makeRow( "vndb_id", "VNDB", item.id, "https://vndb.org/" + item.id ); const rows = [ vndbIdRow, ]; if (item.rating) { rows.push(makeRow( "vndb_rating", "VNDB Rating", "" + item.rating + " (" + item.votecount + ")" )); } if (item.length) { let lengthText = LENGTH_MAP[item.length]; if (item.length_minutes && item.length_votes) { lengthText += " (" + formatMinutes(item.length_minutes) + " from " + item.length_votes + " votes)"; } rows.push(makeRow( "vndb_length", "VNDB Length", lengthText )); } let gogInfoContainer = document.createElement("div"); gogInfoContainer.className = "content-summary-section"; gogInfoContainer.setAttribute("content-summary-section-id", "vndbInfo"); let panelTitle = document.createElement('div'); panelTitle.className = 'title title--no-margin'; let titleText = document.createElement('div'); titleText.className = 'title__underline-text'; titleText.textContent = 'VNDB Information'; panelTitle.appendChild(titleText); gogInfoContainer.appendChild(panelTitle); let panelContent = document.createElement('div'); panelContent.className = 'details table table--without-border'; gogInfoContainer.appendChild(panelContent); rows.forEach(function(row) { panelContent.appendChild(row); }); let sideColumn = document.querySelector('.layout-side-col'); if (sideColumn) { sideColumn.insertBefore(gogInfoContainer, sideColumn.firstChild); } else { console.log("Target container element not found."); } } }); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址