Adds buttons to search for the current game and developer on F95Zone and its forums, and search for the game on Ryuugames. Also autofills and submits the search form on the F95Zone forums search page by clicking the search button.
当前为
// ==UserScript==
// @name F95Zone and Ryuugames Search Buttons for Steam
// @namespace http://tampermonkey.net/
// @version 3.4
// @description Adds buttons to search for the current game and developer on F95Zone and its forums, and search for the game on Ryuugames. Also autofills and submits the search form on the F95Zone forums search page by clicking the search button.
// @author FunkyJustin
// @match https://store.steampowered.com/app/*
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
function createF95ZoneButton() {
const gameTitle = document.querySelector('.apphub_AppName').innerText.trim();
const f95zoneGameLink = `https://f95zone.to/sam/latest_alpha/#/cat=games/page=1/search=${encodeURIComponent(gameTitle)}`;
const f95zoneForumLink = `https://f95zone.to/search/?q=${encodeURIComponent(gameTitle)}&t=post&c[child_nodes]=1&c[nodes][0]=2&c[title_only]=1&o=relevance`;
const ryuugamesLink = `https://www.ryuugames.com/?s=${encodeURIComponent(gameTitle)}`;
const developerElement = document.querySelector('#developers_list a');
const gameButton = createButton('Search on F95Zone', f95zoneGameLink);
const forumButton = createButton('Search on F95Zone Forums', f95zoneForumLink);
const ryuugamesButton = createButton('Search on Ryuugames', ryuugamesLink);
if (developerElement) {
const developerName = developerElement.innerText.trim();
const f95zoneDeveloperLink = `https://f95zone.to/sam/latest_alpha/#/cat=games/page=1/creator=${encodeURIComponent(developerName)}`;
const developerButton = createButton('Search Developer on F95Zone', f95zoneDeveloperLink);
const developerButtonContainer = document.createElement('div');
developerButtonContainer.style.marginTop = '10px'; // Add some margin at the top
developerButtonContainer.appendChild(developerButton);
developerElement.parentElement.appendChild(developerButtonContainer);
developerButton.addEventListener('click', function(event) {
event.preventDefault();
openUniqueTab(f95zoneDeveloperLink);
});
developerButton.addEventListener('auxclick', function(event) {
if (event.button === 1) { // Middle mouse button click
event.preventDefault();
openUniqueTab(f95zoneDeveloperLink);
}
});
}
const titleElement = document.querySelector('.apphub_AppName');
titleElement.parentElement.appendChild(gameButton);
titleElement.parentElement.appendChild(document.createTextNode(' '));
titleElement.parentElement.appendChild(forumButton);
titleElement.parentElement.appendChild(document.createTextNode(' '));
titleElement.parentElement.appendChild(ryuugamesButton);
}
function createButton(text, link) {
const buttonContainer = document.createElement('div');
buttonContainer.className = 'esi-add-note btnv6_blue_hoverfade btn_medium';
buttonContainer.style.margin = '5px 10px 5px 0'; // 5px top, 10px right, 5px bottom, 0px left
buttonContainer.style.overflow = 'hidden'; // Hide overflow content
const button = document.createElement('span');
button.innerText = text;
if (text === 'Search Developer on F95Zone') {
button.style.fontSize = '0.8em'; // Adjust font size for this specific button
}
button.style.whiteSpace = 'nowrap'; // Prevent text wrapping
button.style.overflow = 'hidden'; // Hide overflow content
button.style.textOverflow = 'ellipsis'; // Add ellipsis for overflow text
buttonContainer.appendChild(button);
buttonContainer.addEventListener('click', function(event) {
event.preventDefault(); // Prevent default action
openUniqueTab(link); // Open link in a new tab
});
return buttonContainer;
}
function openUniqueTab(url) {
// Check if a tab for the link is already open
const existingTab = Array.from(window.openedTabs || []).find(tab => tab === url);
if (!existingTab) {
window.open(url, '_blank'); // Open link in a new tab
// Store the opened tab in a list to check against later
window.openedTabs = window.openedTabs || [];
window.openedTabs.push(url);
} else {
existingTab.focus(); // Focus on the existing tab
}
}
// Wait for the game details to load before creating the button
window.addEventListener('load', createF95ZoneButton);
})();