2024-08-10 00:45:28 -07:00
|
|
|
if(typeof browser === "undefined")
|
|
|
|
var browser = chrome;
|
|
|
|
|
2024-08-08 10:34:58 -07:00
|
|
|
const url = window.location.href;
|
2024-08-09 12:36:26 -07:00
|
|
|
|
2024-08-10 16:03:15 -07:00
|
|
|
browser.storage.sync.get('gameEnabled').then((result) => {
|
2024-08-10 00:45:28 -07:00
|
|
|
|
2024-08-10 16:03:15 -07:00
|
|
|
const gameEnabled = result.gameEnabled !== undefined ? result.gameEnabled : true;
|
|
|
|
if(gameEnabled) {
|
|
|
|
|
|
|
|
var appID;
|
|
|
|
if(url.includes('/app/')) {
|
|
|
|
const appIDMatch = url.match(/\/app\/(\d+)/);
|
|
|
|
appID = appIDMatch[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(appID) {
|
|
|
|
|
|
|
|
const buttonContainer = document.querySelector(".apphub_OtherSiteInfo");
|
|
|
|
if(buttonContainer) {
|
2024-08-09 12:36:26 -07:00
|
|
|
|
2024-08-10 16:03:15 -07:00
|
|
|
const sgdb_button = document.createElement('a');
|
|
|
|
sgdb_button.href = `https://steamgriddb.com/steam/${appID}`;
|
|
|
|
sgdb_button.className = "btnv6_blue_hoverfade btn_medium";
|
|
|
|
sgdb_button.style.marginRight = "3px";
|
|
|
|
sgdb_button.style.marginLeft = "3px";
|
|
|
|
|
|
|
|
const span = document.createElement('span');
|
|
|
|
span.setAttribute("data-tooltip-text", "View on SteamGridDB");
|
|
|
|
|
|
|
|
const icon = document.createElement("img");
|
|
|
|
icon.className = "ico16";
|
|
|
|
icon.style.backgroundImage = "none";
|
|
|
|
icon.src = browser.runtime.getURL("icons/sgdb_16.png");
|
|
|
|
|
|
|
|
span.append(icon);
|
|
|
|
sgdb_button.append(span);
|
|
|
|
buttonContainer.prepend(sgdb_button);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2024-08-09 12:36:26 -07:00
|
|
|
|
2024-08-08 10:34:58 -07:00
|
|
|
}
|
|
|
|
|
2024-08-10 16:03:15 -07:00
|
|
|
});
|
2024-08-10 00:45:28 -07:00
|
|
|
|
2024-08-10 16:03:15 -07:00
|
|
|
browser.storage.sync.get('profileEnabled').then((result) => {
|
|
|
|
|
|
|
|
const profileEnabled = result.profileEnabled !== undefined ? result.profileEnabled : false;
|
|
|
|
if(result.profileEnabled) {
|
|
|
|
|
|
|
|
var userID;
|
|
|
|
if(url.includes('/profiles/')) {
|
|
|
|
const userIDMatch = url.match(/\/profiles\/(\d+)/);
|
2024-08-10 00:45:28 -07:00
|
|
|
if(userIDMatch) {
|
|
|
|
userID = userIDMatch[1];
|
2024-08-10 16:03:15 -07:00
|
|
|
}
|
|
|
|
} else if(url.includes('/id/')) {
|
|
|
|
const div = document.getElementById('responsive_page_template_content');
|
|
|
|
if(div) {
|
|
|
|
const scriptElements = div.getElementsByTagName('script');
|
|
|
|
for(script of scriptElements) {
|
|
|
|
const content = script.textContent || script.innerText;
|
|
|
|
const userIDMatch = content.match(/"steamid":"(\d+)"/);
|
|
|
|
if(userIDMatch) {
|
|
|
|
userID = userIDMatch[1];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2024-08-10 00:45:28 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-10 16:03:15 -07:00
|
|
|
if(userID) {
|
2024-08-10 00:45:28 -07:00
|
|
|
|
2024-08-10 16:03:15 -07:00
|
|
|
const headerActions = document.querySelector(".profile_header_actions");
|
|
|
|
if(headerActions) {
|
|
|
|
|
|
|
|
const dropdown = document.getElementById("profile_action_dropdown");
|
|
|
|
if(dropdown) {
|
|
|
|
|
|
|
|
const popup_menu = dropdown.getElementsByClassName("popup_menu");
|
|
|
|
|
|
|
|
const dropdown_button = document.createElement('a');
|
|
|
|
dropdown_button.href = `https://steamgriddb.com/profile/${userID}`;
|
|
|
|
dropdown_button.className = "popup_menu_item";
|
|
|
|
|
|
|
|
const icon = document.createElement("img");
|
|
|
|
icon.src = browser.runtime.getURL("icons/sgdb_16.png");
|
|
|
|
|
|
|
|
dropdown_button.append(icon);
|
|
|
|
dropdown_button.append("\u00A0 SteamGridDB Profile");
|
|
|
|
popup_menu[0].append(dropdown_button);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
const profile_button = document.createElement('a');
|
|
|
|
profile_button.href = `https://steamgriddb.com/profile/${userID}`;
|
|
|
|
profile_button.className = "btn_profile_action btn_medium";
|
|
|
|
profile_button.style.marginRight = "3px";
|
|
|
|
profile_button.style.marginLeft = "3px";
|
2024-08-10 00:45:28 -07:00
|
|
|
|
2024-08-10 16:03:15 -07:00
|
|
|
const span = document.createElement('span');
|
|
|
|
span.setAttribute("data-tooltip-text", "View SteamGridDB profile");
|
2024-08-10 00:45:28 -07:00
|
|
|
|
2024-08-10 16:03:15 -07:00
|
|
|
const icon = document.createElement("img");
|
|
|
|
icon.className = "ico16";
|
|
|
|
icon.style.backgroundImage = "none";
|
|
|
|
icon.src = browser.runtime.getURL("icons/sgdb_16.png");
|
|
|
|
|
|
|
|
span.append(icon);
|
|
|
|
profile_button.append(span);
|
|
|
|
headerActions.append(profile_button);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2024-08-10 00:45:28 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-08-10 16:03:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|