Skip to content

Commit 47544ce

Browse files
authored
Refactor and update _Bridge.js with new features
1 parent be64f28 commit 47544ce

1 file changed

Lines changed: 0 additions & 93 deletions

File tree

examples/_Bridge.js

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -432,96 +432,3 @@ function submitToAutoIt() {
432432
// Reset form after sending
433433
document.getElementById('contactForm').reset();
434434
}
435-
436-
// =======================================================================================================
437-
// GOG Enhancer Logic
438-
// =======================================================================================================
439-
440-
/**
441-
* Applies filters based on the JSON data provided by AutoIt.
442-
* @param {string} jsonData - The JSON string from NetJson.Parser
443-
*/
444-
function applyGOGFilters(jsonData) {
445-
if (!jsonData) return;
446-
447-
// Save to global window variable so setInterval can reuse it during scrolling
448-
window.lastGogData = jsonData;
449-
450-
try {
451-
const data = JSON.parse(jsonData);
452-
453-
// Target GOG game tiles
454-
const tiles = document.querySelectorAll('.product-tile, .big-spot, .product-row');
455-
456-
tiles.forEach(tile => {
457-
const titleEl = tile.querySelector('.product-tile__title, .big-spot__title, .product-row__title');
458-
if (!titleEl) return;
459-
460-
const title = titleEl.innerText.trim();
461-
462-
// 1. Blacklist (Hide)
463-
if (data.Blacklist && data.Blacklist.includes(title)) {
464-
tile.style.display = 'none';
465-
}
466-
// 2. Owned (Fade/Grayscale)
467-
else if (data.Owned && data.Owned.includes(title)) {
468-
tile.style.opacity = '0.25';
469-
tile.style.filter = 'grayscale(100%) brightness(0.7)';
470-
tile.style.pointerEvents = 'none';
471-
}
472-
// 3. Watchlist (Highlight)
473-
else if (data.Watchlist && data.Watchlist.includes(title)) {
474-
tile.style.border = '2px solid #ffc400';
475-
tile.style.backgroundColor = 'rgba(255, 196, 0, 0.05)';
476-
tile.style.boxShadow = 'inset 0 0 15px rgba(255, 196, 0, 0.2)';
477-
}
478-
});
479-
480-
console.log("GOG Filters Applied Successfully");
481-
} catch (e) {
482-
console.error("Error applying GOG filters:", e);
483-
}
484-
}
485-
486-
/**
487-
* Automation: Re-apply filters every 2 seconds to catch new games
488-
* that appear during infinite scrolling.
489-
*/
490-
setInterval(() => {
491-
if (window.lastGogData) {
492-
applyGOGFilters(window.lastGogData);
493-
}
494-
}, 2000);
495-
496-
// =======================================================================================================
497-
// CONTEXT MENU SENSOR
498-
// =======================================================================================================
499-
window.addEventListener('contextmenu', function (e) {
500-
// 1. Ψάχνουμε το tile ή οποιοδήποτε link που μοιάζει με παιχνίδι
501-
let tile = e.target.closest('.product-tile, .big-spot, .product-row, .product-card, a[href*="/game/"]');
502-
let gameTitle = "";
503-
504-
if (tile) {
505-
// Προσπάθεια 1: Από τα γνωστά classes τίτλων
506-
let titleEl = tile.querySelector('.product-tile__title, .big-spot__title, .product-row__title, .product-card__title');
507-
if (titleEl) {
508-
gameTitle = titleEl.innerText.trim();
509-
}
510-
// Προσπάθεια 2: Αν κάναμε κλικ σε link, παίρνουμε το τελευταίο κομμάτι του URL
511-
else if (tile.href && tile.href.includes('/game/')) {
512-
let parts = tile.href.split('/');
513-
gameTitle = parts[parts.length - 1].replace(/_/g, ' '); // π.χ. resident_evil_bundle -> resident evil bundle
514-
}
515-
}
516-
517-
const menuData = {
518-
x: e.clientX,
519-
y: e.clientY,
520-
kind: gameTitle ? "GOG_Game" : "Page",
521-
tagName: e.target.tagName,
522-
link: e.target.closest('a') ? e.target.closest('a').href : "",
523-
selection: gameTitle || window.getSelection().toString()
524-
};
525-
526-
window.chrome.webview.postMessage("JSON:" + JSON.stringify(menuData));
527-
});

0 commit comments

Comments
 (0)