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.2
// @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 gameButton = createButton('Search on F95Zone', f95zoneGameLink);
const forumButton = createButton('Search on F95Zone Forums', f95zoneForumLink);
const ryuugamesButton = createButton('Search on Ryuugames', ryuugamesLink);
// Append buttons below the game title
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);
// Click the search button on F95Zone forums page after loading
if (window.location.href === f95zoneForumLink) {
window.onload = function() {
setTimeout(function() {
const searchField = document.querySelector('.input[name="keywords"]');
if (searchField) {
searchField.value = gameTitle;
searchField.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }));
}
}, 1000); // 1 second delay before pressing Enter
};
}
// Adding the Developer search button
const developerElement = document.querySelector('#developers_list a');
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);
// Create a container for the developer button
const developerButtonContainer = document.createElement('div');
developerButtonContainer.style.marginTop = '10px'; // Add some margin at the top
developerButtonContainer.appendChild(developerButton);
developerElement.parentElement.appendChild(developerButtonContainer);
// Prevent default action of the underlying link for all click types
developerButton.addEventListener('click', function(event) {
event.preventDefault();
window.open(f95zoneDeveloperLink, '_blank');
});
developerButton.addEventListener('auxclick', function(event) {
if (event.button === 1) { // Middle mouse button click
event.preventDefault();
window.open(f95zoneDeveloperLink, '_blank');
}
});
}
}
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
// Check if a tab for the link is already open
const existingTab = window.openedTabs.find(tab => tab === link);
if (!existingTab) {
window.open(link, '_blank'); // Open link in a new tab
// Store the opened tab in a list to check against later
window.openedTabs.push(link);
} else {
existingTab.focus(); // Focus on the existing tab
}
});
return buttonContainer;
}
// Wait for the game details to load before creating the button
window.addEventListener('load', createF95ZoneButton);
})();