From 4871f1ba8d67c4adf8546352eee0f44685aca68e Mon Sep 17 00:00:00 2001 From: avscs <(none)> Date: Tue, 17 Jun 2025 20:10:29 -0400 Subject: [PATCH] better config file system --- index.html | 746 +++++++++++++++++++++++++++----------------------- js/config.js | 1 + js/loading.js | 160 ++++++----- 3 files changed, 483 insertions(+), 424 deletions(-) create mode 100644 js/config.js diff --git a/index.html b/index.html index aa6a75b2..e036e9c6 100644 --- a/index.html +++ b/index.html @@ -1,394 +1,456 @@ - - - - MonkeyGG2 - - - - - - - - - - - - - - - - - -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - + + + + MonkeyGG2 + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + - -
-
-
- MonkeyGG2 Icon + + + + + +
-
-

MonkeyGG2

- - MonkeyGG2 Icon - -
- -
This feature has been disabled by whoever is hosting this MonkeyGG2 instance.
-
-
-

Press Anywhere to cloak

-

(If you want to stop seeing this enable popups)

- Click here if cloak isn't working -
-
-
-
- +
+
+
+
+ -
-
- +
+
+ -
-
- +
+
+ -
+
Settings
+

A ton of customizable settings and features all at your fingertips!

+
+
-
- +
    +
    +
    +
    +

    Settings

    +
    Notice: All changes occur on page refresh
    +
    + + +

    +
    +
    +
    Cloak and Mask Presets
    +

    If the 2 settings are enabled, choose without typing it out

    + - +
    -
      -
      -
      -
      -

      Settings

      -
      Notice: All changes occur on page refresh
      -
      - - -

      -
      -
      -
      Cloak and Mask Presets
      -

      If the 2 settings are enabled, choose without typing it out

      - +
      +
      +
      + +
      +
      +
      Cloak URL
      +

      This site will appear in your history instead of MonkeyGG2.

      + + +
      +
      +
      Mask
      +

      Toggles if mask is applied on loading of a page automatically

      + +
      +
      +
      Mask Title
      +

      This site's title will replace MonkeyGG2's title in your browser tab.

      + + +
      +
      +
      Mask Icon URL
      +

      This site's icon will replace MonkeyGG2's icon in your browser tab. (Don't forget https://)

      + + +
      +
      +
      Shortcuts
      +

      Shortcuts will help some people navigate the site easier. DISCLAIMER!! Certain shortcuts such as CTRL+R + and CTRL+W cannot be overriden manually.

      +
      +
      + +
      +
      Slot 1
      +

      Press a button then press a key on your keyboard to choose

      + +

      +

      + +

      +

      + +

      =

      + -
      -
      -
      Cloak
      -

      Toggles if Cloak (Hides site from history and being view online) is forced

      - +
      +
      Slot 2
      +

      Press a button then press a key on your keyboard to choose

      + +

      +

      + +

      +

      + +

      =

      +
      -
      -
      Cloak URL
      -

      This site will appear in your history instead of MonkeyGG2.

      - - -
      -
      -
      Mask
      -

      Toggles if mask is applied on loading of a page automatically

      - -
      -
      -
      Mask Title
      -

      This site's title will replace MonkeyGG2's title in your browser tab.

      - - -
      -
      -
      Mask Icon URL
      -

      This site's icon will replace MonkeyGG2's icon in your browser tab. (Don't forget https://)

      - - -
      -
      -
      Shortcuts
      -

      Shortcuts will help some people navigate the site easier. DISCLAIMER!! Certain shortcuts such as CTRL+R and CTRL+W cannot be overriden manually.

      -
      -
      - -
      -
      Slot 1
      -

      Press a button then press a key on your keyboard to choose

      - -

      +

      - -

      +

      - -

      =

      - -
      -
      -
      Slot 2
      -

      Press a button then press a key on your keyboard to choose

      - -

      +

      - -

      +

      - -

      =

      - -
      -
      -
      Slot 3
      -

      Press a button then press a key on your keyboard to choose

      - -

      +

      - -

      +

      - -

      =

      - -
      -
      -
      -
      Background
      -

      Background can cause a lot of lag. Disable if your computer is diagnosed with low FPS.

      - -
      -

      Appearance

      -
      -
      Custom Theme (change on refresh)
      - - -
      - - -
      - - -
      - - -
      - - -
      - - -
      - - -
      - - -
      - - +
      +
      Slot 3
      +

      Press a button then press a key on your keyboard to choose

      + +

      +

      + +

      +

      + +

      =

      +
      +
      +
      Background
      +

      Background can cause a lot of lag. Disable if your computer is diagnosed with low FPS.

      + +
      +

      Appearance

      +
      +
      Custom Theme (change on refresh)
      + + +
      + + +
      + + +
      + + +
      + + +
      + + +
      + + +
      + + +
      + + +
      -
      -
      - - - -
      - - - - - - - - - +
      + +
      + + + +
      + + + + + + + + diff --git a/js/config.js b/js/config.js new file mode 100644 index 00000000..6b79a487 --- /dev/null +++ b/js/config.js @@ -0,0 +1 @@ +var json={"games":{"2048":{"path":"2048","aliases":[],"categories":[]},"1v1.LOL":{"path":"1v1-lol","aliases":[],"categories":["online","battle"]},"10 minutes till dawn":{"path":"10-minutes-till-dawn","aliases":[],"categories":[]},"Achievement Unlocked":{"path":"flash/?game=achievement-unlocked","aliases":[],"categories":[]},"Achievement Unlocked 2":{"path":"flash/?game=achievement-unlocked-2","aliases":[],"categories":[]},"Achievement Unlocked 3":{"path":"flash/?game=achievement-unlocked-3","aliases":[],"categories":[]},"A Dark Room":{"path":"a-dark-room","aliases":[],"categories":[]},"Abandoned":{"path":"abandoned","aliases":[],"categories":["escape"]},"Abandoned 2":{"path":"abandoned-2","aliases":[],"categories":[]},"Ages of Conflict":{"path":"ages-of-conflict","aliases":[],"categories":["escape"]},"Age of War":{"path":"flash/?game=age-of-war","aliases":[],"categories":[]},"Age of War Hacked":{"path":"flash/?game=age-of-war-hacked","aliases":[],"categories":[]},"Aground":{"path":"aground","aliases":[],"categories":[]},"Amidst The Sky":{"path":"amidst-the-sky","aliases":[],"categories":[]},"Another Gentlemans Adventure":{"path":"another-gentlemans-adventure","aliases":[],"categories":[]},"Awesome Tanks":{"path":"awesome-tanks","aliases":[],"categories":[]},"Awesome Tanks 2":{"path":"awesome-tanks-2","aliases":[],"categories":[]},"Babel Tower":{"path":"babel-tower","aliases":[],"categories":[]},"Basket Random":{"path":"basket-random","aliases":[],"categories":[]},"Basketball Stars":{"path":"basketball-stars","aliases":[],"categories":[]},"Bit Life":{"path":"bit-life","aliases":[],"categories":[]},"Boxing Random":{"path":"boxing-random","aliases":[],"categories":[]},"Bloons":{"path":"flash/?game=bloons","aliases":[],"categories":[]},"Bloons TD 1":{"path":"flash/?game=bloons-td-1","aliases":[],"categories":[]},"Bloons TD 2":{"path":"flash/?game=bloons-td-2","aliases":[],"categories":[]},"Bloons TD 3":{"path":"flash/?game=bloons-td-3","aliases":[],"categories":[]},"Bloons TD 4":{"path":"flash/?game=bloons-td-4","aliases":[],"categories":[]},"Bloons TD 5":{"path":"flash/?game=bloons-td-5","aliases":[],"categories":[]},"Bloxorz":{"path":"flash/?game=bloxorz","aliases":[],"categories":[]},"Brawl Stars Project Laser":{"path":"brawl-stars-project-laser","aliases":[],"categories":[]},"Breaklock":{"path":"breaklock","aliases":[],"categories":[]},"Cat Ninja":{"path":"flash/?game=cat-ninja","aliases":[],"categories":[]},"Curveball":{"path":"flash/?game=curveball","aliases":[],"categories":[]},"Chrome Dino":{"path":"chrome-dino","aliases":[],"categories":[]},"Clicker Heroes":{"path":"clicker-heroes","aliases":[],"categories":[]},"Clicker Heroes Updated":{"path":"clicker-heroes-updated","aliases":[],"categories":[]},"Cookie Clicker":{"path":"cookie-clicker","aliases":[],"categories":[]},"Core Ball":{"path":"core-ball","aliases":[],"categories":[]},"Crossy Road":{"path":"crossy-road","aliases":[],"categories":[]},"Conway's Game of Life":{"path":"conways-game-of-life","aliases":[],"categories":[]},"Creative Kill Chamber":{"path":"flash/?game=creative-kill-chamber","aliases":[],"categories":[]},"Cut The Rope":{"path":"cut-the-rope","aliases":[],"categories":[]},"Dadish":{"path":"dadish","aliases":[],"categories":[]},"Dadish 2":{"path":"dadish-2","aliases":[],"categories":[]},"Dadish 3":{"path":"dadish-3","aliases":[],"categories":[]},"Doge Miner":{"path":"doge-miner","aliases":[],"categories":[]},"Don't Escape":{"path":"flash/?game=dont-escape","aliases":[],"categories":[]},"Don't Escape 2":{"path":"flash/?game=dont-escape-2","aliases":[],"categories":[]},"Don't Escape 3":{"path":"flash/?game=dont-escape-3","aliases":[],"categories":[]},"Doodle Jump":{"path":"doodle-jump","aliases":[],"categories":[]},"Drift Boss":{"path":"drift-boss","aliases":[],"categories":[]},"Drift Hunters":{"path":"drift-hunters","aliases":[],"categories":[]},"Drive Mad":{"path":"drive-mad","aliases":[],"categories":[]},"Drive Mad S":{"path":"drive-mad-s","aliases":[],"categories":[]},"Duck Life":{"path":"flash/?game=duck-life","aliases":[],"categories":[]},"Duck Life 2":{"path":"flash/?game=duck-life-2","aliases":[],"categories":[]},"Duck Life 3":{"path":"flash/?game=duck-life-3","aliases":[],"categories":[]},"Duck Life 4":{"path":"duck-life-4","aliases":[],"categories":[]},"Duck Life Treasure Hunt":{"path":"flash/?game=duck-life-treasure-hunt","aliases":[],"categories":[]},"Dune!":{"path":"dune","aliases":[],"categories":[]},"Eaglercraft Ampler Launcher":{"path":"ampler-launcher","aliases":[],"categories":[]},"Eggy Car":{"path":"eggy-car","aliases":[],"categories":[]},"EvoWars":{"path":"evowars","aliases":[],"categories":[]},"Escape The Car":{"path":"flash/?game=escape-the-car","aliases":[],"categories":[]},"Escape The Closet":{"path":"flash/?game=escape-the-closet","aliases":[],"categories":[]},"Escape The Phonebooth":{"path":"flash/?game=escape-the-phonebooth","aliases":[],"categories":[]},"Escape The Bathroom":{"path":"flash/?game=escape-the-bathroom","aliases":[],"categories":[]},"Escape The Freezer":{"path":"flash/?game=escape-the-freezer","aliases":[],"categories":[]},"Escape The Shack":{"path":"flash/?game=escape-the-shack","aliases":[],"categories":[]},"Family Feud":{"path":"family-feud","aliases":[],"categories":[]},"Fireboy and Watergirl in the Forest Temple":{"path":"fireboy-and-watergirl","aliases":["Fireboy and Watergirl","Fireboy and Watergirl 1"],"categories":[]},"Fireboy and Watergirl in the Light Temple":{"path":"fireboy-and-watergirl-2","aliases":["Fireboy and Watergirl 2"],"categories":[]},"Fireboy and Watergirl in the Ice Temple":{"path":"fireboy-and-watergirl-3","aliases":["Fireboy and Watergirl 3"],"categories":[]},"Fireboy and Watergirl in the Crystal Temple":{"path":"fireboy-and-watergirl-4","aliases":["Fireboy and Watergirl 4"],"categories":[]},"Flash Chess":{"path":"flash/?game=flash-chess","aliases":[],"categories":[]},"Friday Night Funkin":{"path":"friday-night-funkin","aliases":[],"categories":[]},"Factory Balls":{"path":"flash/?game=factory-balls","aliases":[],"categories":[]},"Flappy Bird":{"path":"flappy-bird","aliases":[],"categories":[]},"Geometry Dash Lite":{"path":"geometry-dash-lite","aliases":[],"categories":[]},"Geometry Dash Remastered":{"path":"geometry-dash-remastered","aliases":[],"categories":[]},"Geometry Vibes":{"path":"geometry-vibes","aliases":[],"categories":[]},"Geometry Vibes Monster":{"path":"geometry-vibes-monster","aliases":[],"categories":[]},"Geometry Vibes X-Ball":{"path":"geometry-vibes-x-ball","aliases":[],"categories":[]},"Getaway Shootout":{"path":"getaway-shootout","aliases":[],"categories":[]},"Gons io":{"path":"gons-io","aliases":[],"categories":[]},"Gun Mayhem":{"path":"flash/?game=gun-mayhem","aliases":[],"categories":[]},"Gun Mayhem 2":{"path":"flash/?game=gun-mayhem-2","aliases":[],"categories":[]},"Gun Spin":{"path":"gunspin","aliases":[],"categories":[]},"Henry Stickmin 0: Breaking The Bank":{"path":"flash/?game=breaking-the-bank","aliases":[],"categories":[]},"Henry Stickmin 1: Escaping The Prison":{"path":"flash/?game=escaping-the-prison","aliases":[],"categories":[]},"Henry Stickmin 2: Stealing The Diamond":{"path":"flash/?game=stealing-the-diamond","aliases":[],"categories":[]},"Henry Stickmin 3: Infiltrating The Airship":{"path":"flash/?game=infiltrating-the-airship","aliases":[],"categories":[]},"Henry Stickmin 4: Fleeing the Complex":{"path":"flash/?game=fleeing-the-complex","aliases":[],"categories":[]},"Hextris":{"path":"hextris","aliases":[],"categories":[]},"Incremancer":{"path":"incremancer","aliases":[],"categories":[]},"Learn To Fly":{"path":"flash/?game=learn-to-fly","aliases":[],"categories":[]},"Learn To Fly 2":{"path":"flash/?game=learn-to-fly-2","aliases":[],"categories":[]},"Learn To Fly 3":{"path":"flash/?game=learn-to-fly-3","aliases":[],"categories":[]},"Learn To Fly Idle":{"path":"flash/?game=learn-to-fly-idle","aliases":[],"categories":[]},"Lion Solider's Vengeance":{"path":"lion-soldiers-vengeance","aliases":[],"cateogires":[]},"Idle Breakout":{"path":"idle-breakout","aliases":[],"categories":[]},"Maptroid":{"path":"maptroid","aliases":[],"categories":[]},"Mario":{"path":"mario-game","aliases":[],"categories":[]},"Monkey Mart":{"path":"monkey-mart","aliases":[],"categories":[]},"MotoX3M":{"path":"motox3m","aliases":[],"categories":[]},"N-gon":{"path":"n-gon","aliases":[],"categories":[]},"N Step Steve Part 1":{"path":"n-step-steve-part-1","aliases":[],"categories":[]},"N Step Steve Part 2":{"path":"n-step-steve-part-2","aliases":[],"categories":[]},"OvO":{"path":"ovo/1.4.4","aliases":[],"categories":[]},"OvO 2":{"path":"ovo/2.0.2alpha","aliases":[],"categories":[]},"Papas Pizzeria":{"path":"flash/?game=papas-pizzaria","aliases":[],"categories":[]},"Papas Freezeria":{"path":"flash/?game=papas-freezeria","aliases":[],"categories":[]},"Particle Clicker":{"path":"particle-clicker","aliases":[],"categories":[]},"Planet Life":{"path":"planet-life","aliases":[],"categories":[]},"P.craft":{"path":"pcraft","aliases":[],"categories":[]},"Progress Knight Quest":{"path":"progress-knight-quest","aliases":[],"categories":[]},"Progress Knight Reborn":{"path":"progress-knight-reborn","aliases":[],"categories":[]},"Pull Of War":{"path":"pull-of-war","aliases":[],"categories":[]},"Reach The Core":{"path":"reach-the-core","aliases":[],"categories":[]},"Restless Wing Syndrome":{"path":"restless-wing-syndrome","aliases":[],"categories":[]},"Raft Wars":{"path":"flash/?game=raft-wars","aliases":[],"categories":[]},"Raft Wars 2":{"path":"flash/?game=raft-wars-2","aliases":[],"categories":[]},"Retro Bowl":{"path":"retro-bowl","aliases":[],"categories":[]},"Retro Bowl Old":{"path":"retro-bowl-old","aliases":[],"categories":[]},"Rift Shift":{"path":"rift-shift","aliases":[],"categories":[]},"Rocket League 2D":{"path":"rocket-league-2d","aliases":[],"categories":[]},"Rogue Soul":{"path":"flash/?game=rogue-soul","aliases":[],"categories":[]},"Rogue Soul 2":{"path":"flash/?game=rogue-soul-2","aliases":[],"categories":[]},"Riddle School":{"path":"flash/?game=riddle-school","aliases":[],"categories":["escape"]},"Riddle School 2":{"path":"flash/?game=riddle-school-2","aliases":[],"categories":["escape"]},"Riddle School 3":{"path":"flash/?game=riddle-school-3","aliases":[],"categories":["escape"]},"Riddle School 4":{"path":"flash/?game=riddle-school-4","aliases":[],"categories":["escape"]},"Riddle School 5":{"path":"flash/?game=riddle-school-5","aliases":[],"categories":["escape"]},"Riddle Transfer":{"path":"flash/?game=riddle-transfer","aliases":[],"categories":["escape"]},"Riddle Transfer 2":{"path":"flash/?game=riddle-transfer-2","aliases":[],"categories":["escape"]},"Rooftop Snipers":{"path":"rooftop-snipers","aliases":[],"categories":[]},"Rookie Bowman":{"path":"rookie-bowman","aliases":[],"categories":[]},"Run 3":{"path":"run-3","aliases":[],"categories":[]},"Run 3 Beta (may not work)":{"path":"run-3-beta","aliases":[],"categories":[]},"Sabercut":{"path":"sabercut","aliases":[],"categories":[]},"Sandspiel":{"path":"sandspiel","aliases":[],"categories":[]},"Scuba Bear":{"path":"scuba-bear","aliases":[],"categories":[]},"Shadow Fight":{"path":"shadow-fight","aliases":[],"categories":[]},"Slope":{"path":"slope","aliases":[],"categories":[]},"Smash Karts":{"path":"smash-karts","aliases":[],"categories":[]},"Soccer Random":{"path":"soccer-random","aliases":[],"categories":[]},"Station Saturn":{"path":"station-saturn","aliases":[],"categories":[]},"Stickman Hook":{"path":"stickman-hook","aliases":[],"categories":[]},"Subway Surfers":{"path":"subway-surfers","aliases":[],"categories":[]},"Subway Surfers New York":{"path":"subway-surfers-ny","aliases":[],"categories":[]},"Stick RPG Complete":{"path":"flash/?game=stick-rpg-complete","aliases":[],"categories":[]},"Stick War":{"path":"flash/?game=stick-war","aliases":[],"categories":[]},"Submachine":{"path":"flash/?game=submachine","aliases":[],"categories":["escape"]},"Submachine 2":{"path":"flash/?game=submachine-2","aliases":[],"categories":["escape"]},"Submachine 3":{"path":"flash/?game=submachine-3","aliases":[],"categories":["escape"]},"Submachine 4":{"path":"flash/?game=submachine-4","aliases":[],"categories":["escape"]},"Submachine 5":{"path":"flash/?game=submachine-5","aliases":[],"categories":["escape"]},"Submachine 6":{"path":"flash/?game=submachine-6","aliases":[],"categories":["escape"]},"Submachine 7":{"path":"flash/?game=submachine-7","aliases":[],"categories":["escape"]},"Submachine 8":{"path":"flash/?game=submachine-8","aliases":[],"categories":["escape"]},"Submachine 9":{"path":"flash/?game=submachine-9","aliases":[],"categories":["escape"]},"Submachine 10":{"path":"flash/?game=submachine-10","aliases":[],"categories":["escape"]},"Submachine 0":{"path":"flash/?game=submachine-0","aliases":[],"categories":["escape"]},"Submachine 32 Chambers":{"path":"flash/?game=submachine-32-chambers","aliases":[],"categories":["escape"]},"Submachine FLF":{"path":"flash/?game=submachine-flf","aliases":[],"categories":["escape"]},"Sugar Sugar":{"path":"flash/?game=sugar-sugar","aliases":[],"categories":[]},"Swords and Souls":{"path":"flash/?game=swords-and-souls","aliases":[],"categories":[]},"The Final Earth":{"path":"the-final-earth","aliases":[],"categories":[]},"The Treasure":{"path":"the-treasure","aliases":[],"categories":["escape"]},"There Is No Game":{"path":"there-is-no-game","aliases":[],"categories":[]},"Tic Tac What?":{"path":"tic-tac-what","aliases":[],"categories":[]},"Time Shooter":{"path":"time-shooter","aliases":[],"categories":[]},"Time Shooter 3":{"path":"time-shooter-3","aliases":[],"categories":[]},"Tiny Fishing":{"path":"tiny-fishing","aliases":[],"categories":[]},"Trace":{"path":"trace","aliases":[],"categories":["escape"]},"Tanuki Sunset":{"path":"tanuki-sunset","aliases":[],"categories":[]},"Temple Run 2":{"path":"temple-run-2","aliases":[],"categories":[]},"The Impossible Quiz":{"path":"flash/?game=the-impossible-quiz","aliases":[],"categories":[]},"This Is The Only Level":{"path":"flash/?game=this-is-the-only-level","aliases":[],"categories":[]},"This Is The Only Level 2":{"path":"flash/?game=this-is-the-only-level-2","aliases":[],"categories":[]},"Tunnel Rush":{"path":"tunnel-rush","aliases":[],"categories":[]},"Two Ball 3d":{"path":"two-ball-3d","aliases":[],"categories":[]},"Vex 3":{"path":"vex-3","aliases":[],"categories":[]},"Vex 4":{"path":"vex-4","aliases":[],"categories":[]},"Vex 5":{"path":"vex-5","aliases":[],"categories":[]},"Vex 6":{"path":"vex-6","aliases":[],"categories":[]},"Vex 7":{"path":"vex-7","aliases":[],"categories":[]},"Volley Random":{"path":"volley-random","aliases":[],"categories":[]},"Web OSU":{"path":"web-osu","aliases":[],"categories":[]},"Ultimate Chess":{"path":"flash/?game=ultimate-chess","aliases":[],"categories":[]},"X Trench Run":{"path":"x-trench-run","aliases":[],"categories":[]},"Yohoho":{"path":"yohoho","aliases":[],"categories":[]}},"themes":{},"config":{"proxy":true,"proxyPath":"https://monkey.nordparrot.ro"}} \ No newline at end of file diff --git a/js/loading.js b/js/loading.js index 5a16464d..a8b60a5f 100644 --- a/js/loading.js +++ b/js/loading.js @@ -1,7 +1,3 @@ -let config; -let games; -let themes; - function changeLoadingTip() { const tips = [ 'Welcome to the land of Nothing!', @@ -24,88 +20,88 @@ let changeTip = setInterval(() => { changeLoadingTip(); }, 3000); -fetch('./config.jsonc') - .then((e) => e.text()) - .then((jsonc) => { - // removing all the comments from the jsonc file - let json = JSON.parse(jsonc.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m, g) => (g ? '' : m))); - games = json['games']; - themes = json['themes']; - config = json['config']; +let games = json['games']; +let themes = json['themes']; +let config = json['config']; - let gamesList = $('#gamesList'); - for (game in games) { - gamesList.append( - `
    • ${game}
    • ` - ); - } - - let starredGamesList = JSON.parse(localStorage.getItem('starredGamesList')) || []; - const stars = document.querySelectorAll('.star'); - stars.forEach((star) => { - star.addEventListener('click', function (event) { - event.preventDefault(); - event.stopPropagation(); - star.classList.toggle('filled'); - - const gameItem = star.parentNode; - var gameName = gameItem.textContent; - const isStarred = starredGamesList.includes(gameName); - - if (isStarred) { - starredGamesList = starredGamesList.filter((gameName) => gameName !== gameName); - - //THIS DOES NOT PUT THE GAME BACK IN ORDER ACCORDING TO THE WAY THE USER SORTED IT - //so for the weird ppl that sort by reverse alphabetical it should act pretty weird - //this is bc im layz and copy pasted this alphabetical sort thing, ill implement based off users sort later - const gameItem = star.closest('li'); - const parent = gameItem.parentNode; - - const originalPosition = Array.from(parent.children) - .sort((a, b) => a.textContent.localeCompare(b.textContent)) - .findIndex((item) => item === gameItem); - - parent.removeChild(gameItem); - - parent.insertBefore(gameItem, parent.children[originalPosition]); - } else { - starredGamesList.unshift(gameName); - } - - localStorage.setItem('starredGamesList', JSON.stringify(starredGamesList)); - updateGameList(); - }); - }); - // Pushes all starred games to the top - function updateGameList() { - const gamesList = document.getElementById('gamesList'); - const children = Array.from(gamesList.children); - - children.forEach((gameItem) => { - const currentGameName = gameItem.textContent; - const stars = gameItem.querySelector('.star'); - - if (starredGamesList.includes(currentGameName)) { - stars.classList.add('filled'); - gamesList.insertBefore(gameItem, gamesList.firstChild); - } - }); +let gamesList = $('#gamesList'); +for (game in games) { + gamesList.append( + `
    • ${game}
    • `, + ); +} + +let starredGamesList = JSON.parse(localStorage.getItem('starredGamesList')) || []; +const stars = document.querySelectorAll('.star'); +stars.forEach((star) => { + star.addEventListener('click', function (event) { + event.preventDefault(); + event.stopPropagation(); + star.classList.toggle('filled'); + + const gameItem = star.parentNode; + var gameName = gameItem.textContent; + const isStarred = starredGamesList.includes(gameName); + + if (isStarred) { + starredGamesList = starredGamesList.filter((gameName) => gameName !== gameName); + + //THIS DOES NOT PUT THE GAME BACK IN ORDER ACCORDING TO THE WAY THE USER SORTED IT + //so for the weird ppl that sort by reverse alphabetical it should act pretty weird + //this is bc im layz and copy pasted this alphabetical sort thing, ill implement based off users sort later + const gameItem = star.closest('li'); + const parent = gameItem.parentNode; + + const originalPosition = Array.from(parent.children) + .sort((a, b) => a.textContent.localeCompare(b.textContent)) + .findIndex((item) => item === gameItem); + + parent.removeChild(gameItem); + + parent.insertBefore(gameItem, parent.children[originalPosition]); + } else { + starredGamesList.unshift(gameName); } + localStorage.setItem('starredGamesList', JSON.stringify(starredGamesList)); updateGameList(); - - $('#gamesList li').on('click', function () { - let url = $(this).attr('url'); - inGame = true; - $('#everything-else').fadeOut(); - $('#page-loader').fadeIn(); - $('#page-loader iframe').attr('src', url); - $('#page-loader iframe')[0].focus(); - currentMenu = $('#page-loader'); - }); }); +}); +// Pushes all starred games to the top +function updateGameList() { + const gamesList = document.getElementById('gamesList'); + const children = Array.from(gamesList.children); + + children.forEach((gameItem) => { + const currentGameName = gameItem.textContent; + const stars = gameItem.querySelector('.star'); + + if (starredGamesList.includes(currentGameName)) { + stars.classList.add('filled'); + gamesList.insertBefore(gameItem, gamesList.firstChild); + } + }); +} + +updateGameList(); + +$('#gamesList li').on('click', function () { + let url = $(this).attr('url'); + if (window.location.protocol === 'file:' && !url.includes('.html')) { + const searchParamsIndex = url.indexOf('?'); + if (searchParamsIndex !== -1) + url = url.substring(0, searchParamsIndex) + 'index.html' + url.substring(searchParamsIndex); + else url += '/index.html'; + } + inGame = true; + $('#everything-else').fadeOut(); + $('#page-loader').fadeIn(); + $('#page-loader iframe').attr('src', url); + $('#page-loader iframe')[0].focus(); + currentMenu = $('#page-loader'); +}); $(window).on('load', () => { $('.track').attr('stroke', 'url(#grad2)'); @@ -122,7 +118,7 @@ $(window).on('load', () => { duration: 500, easing: 'swing', }, - 200 + 200, ); }, 100); },