I think that in this conversation = vs == no point. You change window.location before calling EnQueueHatBank , so before the function is called, you go to a new page. This is what prevents him from running. So the first thing you need to do is:
First call EnQueueHatBank.
if (location.href === 'http://www.scrap.tf/hats') { EnQueueHatBank(); } else { EnQueueHatBank(); window.location.href='http://www.scrap.tf/hats'; }
Clear the code a bit, because the structure is a little inconvenient. You call EnQueueHatBank anyway, so there is no need for it to be in the if statement:
EnQueueHatBank(); if (window.location.href !== 'http://www.scrap.tf/hats') { window.location.href = 'http://www.scrap.tf/hats'; }
Finally, remember that http://www.scrap.tf/hats/ probably refers to the same place as http://www.scrap.tf/hats , not to mention https://www.scrap.tf/hats?foo=bar etc. You would be better off doing a less rigorous test:
EnQueueHatBank(); if (window.location.href.indexOf('://www.scrap.tf/hats') > -1) { window.location.href = 'http://www.scrap.tf/hats'; }
EDIT: Based on your comment, you will need to do this:
if (window.location.href.indexOf('://www.scrap.tf/hats') > -1) { EnQueueHatBank(); } else { window.location.href = 'http://www.scrap.tf/hats'; }
This will only work if your program starts up again after going to scrap.tf/hats , so make sure it starts every time you load a new page.
For security reasons, you cannot initiate code on one page and continue after you have moved to another place. You will need to call EnQueueHatBank from the page on which it was supposed to work.
source share