Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gracehuynhh committed Mar 9, 2024
1 parent 573425e commit 5fec802
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions js/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,11 @@ window.addEventListener('load', function() {
});


// This function checks the URL and redirects if necessary
function ensureURLParameter() {
function ensureURLParameter() {
var currentURL = window.location.href.replace(/^https?:\/\//, ''); // Remove the protocol

var targetPaths = [
'retrobowl-unblocked.github.io/',
'retrobowl-unblocked.github.io/', // Main page
'retrobowl-unblocked.github.io/detail/retro-bowl.html',
'retrobowl-unblocked.github.io/detail/drive-mad.html',
'retrobowl-unblocked.github.io/detail/monkey-mart.html',
Expand All @@ -159,8 +158,10 @@ window.addEventListener('load', function() {
'retrobowl-unblocked.github.io/detail/raft-wars-2.html'
];

// Check if the current URL path is in the list of target paths
if (targetPaths.some(path => currentURL.includes(path)) && !currentURL.includes('?v=1')) {
// Check if the current URL path exactly matches any path in the list
var matchFound = targetPaths.includes(currentURL.split('?')[0].split('#')[0]);

if (matchFound && !currentURL.includes('?v=1')) {
// Append ?v=1 if it's not already present
var newURL = window.location.protocol + '//' + currentURL;
newURL += currentURL.includes('?') ? '&v=1' : '?v=1';
Expand All @@ -171,4 +172,4 @@ window.addEventListener('load', function() {
}

// Call the function when the page loads
ensureURLParameter();
ensureURLParameter();

0 comments on commit 5fec802

Please sign in to comment.