adds .local/share/millennium and easyeffects
This commit is contained in:
+133
@@ -0,0 +1,133 @@
|
||||
// Wait for both DOM and stylesheets to be loaded
|
||||
function waitForStyles() {
|
||||
return new Promise((resolve) => {
|
||||
if (document.styleSheets.length > 0) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
const observer = new MutationObserver((mutations, obs) => {
|
||||
if (document.styleSheets.length > 0) {
|
||||
obs.disconnect();
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
|
||||
observer.observe(document.head, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function initializeExtension() {
|
||||
try {
|
||||
console.log('[ProtonDB] Waiting for styles to load...');
|
||||
await waitForStyles();
|
||||
console.log('[ProtonDB] Styles loaded, proceeding with initialization');
|
||||
|
||||
const appId = getAppId();
|
||||
if (!appId) {
|
||||
console.error('[ProtonDB] Could not find app ID');
|
||||
return;
|
||||
}
|
||||
|
||||
// Process the main game section
|
||||
const parentDiv = document.querySelector(".user_reviews");
|
||||
if (!parentDiv) {
|
||||
console.error('[ProtonDB] Could not find .user_reviews element');
|
||||
return;
|
||||
}
|
||||
|
||||
const appHeaderContent = document.querySelector(".highlight_overflow");
|
||||
if (!appHeaderContent) {
|
||||
console.error('[ProtonDB] Could not find .highlight_overflow element');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('[ProtonDB] Found required DOM elements');
|
||||
appHeaderContent.setAttribute("data-ds-appid", appId);
|
||||
|
||||
// Only add icon if not in excluded classes
|
||||
if (!hasAnyClass(appHeaderContent, ClassNamesToCheck) &&
|
||||
!hasAnyParentClass(appHeaderContent, ClassNamesToCheckInParent)) {
|
||||
addIconToItem(appHeaderContent);
|
||||
}
|
||||
|
||||
try {
|
||||
// Get game data
|
||||
const gameData = await new Promise((resolve, reject) => {
|
||||
browserAPI.runtime.sendMessage(
|
||||
{ contentScriptQuery: "queryGame", appId: appId },
|
||||
(response) => {
|
||||
if (browserAPI.runtime.lastError) {
|
||||
reject(browserAPI.runtime.lastError);
|
||||
return;
|
||||
}
|
||||
resolve(response);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
if (!gameData) {
|
||||
console.error('[ProtonDB] No game data received');
|
||||
return;
|
||||
}
|
||||
|
||||
// Create and add rank rows
|
||||
const rankRowsContainer = document.createElement("div");
|
||||
rankRowsContainer.classList.add("protondb_rank_rows");
|
||||
rankRowsContainer.appendChild(
|
||||
createRankRow("ProtonDB Rank:", gameData.tier, gameData.tier)
|
||||
);
|
||||
rankRowsContainer.appendChild(
|
||||
createRankRow("Trending Rank:", gameData.trendingTier, gameData.trendingTier)
|
||||
);
|
||||
parentDiv.appendChild(rankRowsContainer);
|
||||
|
||||
// Get platform data
|
||||
const platformData = await new Promise((resolve, reject) => {
|
||||
browserAPI.runtime.sendMessage(
|
||||
{ contentScriptQuery: "queryPlatforms", appId },
|
||||
(response) => {
|
||||
if (browserAPI.runtime.lastError) {
|
||||
reject(browserAPI.runtime.lastError);
|
||||
return;
|
||||
}
|
||||
resolve(response);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
if (platformData) {
|
||||
parentDiv.appendChild(createPlatformRow(platformData.linux));
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('[ProtonDB] Error fetching data:', error.message);
|
||||
}
|
||||
|
||||
// Process all game links on the page
|
||||
const gameLinks = document.querySelectorAll('a[href^="https://store.steampowered.com/app/"]');
|
||||
gameLinks.forEach(item => {
|
||||
if (!items.has(item) &&
|
||||
!hasAnyClass(item, ClassNamesToCheck) &&
|
||||
!hasAnyParentClass(item, ClassNamesToCheckInParent)) {
|
||||
addElementsToItems(item);
|
||||
}
|
||||
});
|
||||
|
||||
// Start the observers from utils/observers.js
|
||||
startObservers();
|
||||
|
||||
} catch (error) {
|
||||
console.error('[ProtonDB] Initialization error:', error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize when the page is ready
|
||||
if (document.readyState === 'complete') {
|
||||
initializeExtension();
|
||||
} else {
|
||||
window.addEventListener('load', initializeExtension);
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
const DEFAULT_COLOR_PALETTE = {
|
||||
platinumColor: "#B4C7DC",
|
||||
goldColor: "#CFB53B",
|
||||
silverColor: "#A6A6A6",
|
||||
bronzeColor: "#CD7F32",
|
||||
borkedColor: "#FF0000",
|
||||
unknownColor: "#3D3D3D",
|
||||
};
|
||||
|
||||
var colorPickers = document.querySelectorAll(".custom-color-picker");
|
||||
|
||||
function getStoredColorPalette(callback) {
|
||||
chrome.storage.local.get(DEFAULT_COLOR_PALETTE, callback);
|
||||
}
|
||||
|
||||
function saveColors(event) {
|
||||
const pickerFor = event.target.parentElement.getAttribute("picker-for");
|
||||
|
||||
let currentColorPalette;
|
||||
getStoredColorPalette((colorPalette) => {
|
||||
currentColorPalette = colorPalette;
|
||||
});
|
||||
|
||||
const newColorPalette = {
|
||||
...currentColorPalette,
|
||||
[`${pickerFor}Color`]: event.target.value,
|
||||
};
|
||||
|
||||
chrome.storage.local.set(newColorPalette);
|
||||
|
||||
updateColorPickers(newColorPalette);
|
||||
}
|
||||
|
||||
function loadColors() {
|
||||
getStoredColorPalette(updateColorPickers);
|
||||
}
|
||||
|
||||
function updateColorPickers(newColorPalette) {
|
||||
colorPickers.forEach((colorPicker) => {
|
||||
const pickerFor = colorPicker.getAttribute("picker-for");
|
||||
const colorPickerInput = colorPicker.querySelector("input");
|
||||
|
||||
colorPickerInput.value = newColorPalette[`${pickerFor}Color`];
|
||||
colorPicker.style.backgroundColor = newColorPalette[`${pickerFor}Color`];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function resetColors() {
|
||||
if (!confirm("Are you sure you want to reset the colors to default values?")) {
|
||||
return;
|
||||
}
|
||||
chrome.storage.local.set(DEFAULT_COLOR_PALETTE, loadColors);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Event Listeners */
|
||||
|
||||
window.addEventListener("DOMContentLoaded", function () {
|
||||
loadColors();
|
||||
});
|
||||
|
||||
colorPickers.forEach((colorPicker) => {
|
||||
const colorPickerInput = colorPicker.querySelector("input");
|
||||
|
||||
colorPicker.addEventListener("click", (event) => {
|
||||
colorPickerInput.click();
|
||||
});
|
||||
|
||||
colorPickerInput.addEventListener("input", saveColors);
|
||||
});
|
||||
|
||||
document.getElementById("resetColorsButton").addEventListener("click", resetColors);
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// Initialize colors
|
||||
setColors();
|
||||
|
||||
const newItems = getNewItems();
|
||||
if (newItems.length > 0) {
|
||||
newItems.forEach((item) => {
|
||||
if (!items.has(item) &&
|
||||
!hasAnyClass(item, ClassNamesToCheck) &&
|
||||
!hasAnyParentClass(item, ClassNamesToCheckInParent)) {
|
||||
addElementsToItems(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Start the observers from utils/observers.js
|
||||
startObservers();
|
||||
Reference in New Issue
Block a user