2

so as you about to learn, I don't know javascript, but this seems like it should work:

var whitelistURLPartials = ["ae\=Folder","ae\=Item\&t\=IPM\.Note"];

var current = window.location.href;

for (var whitelist in whitelistURLPartials)
{
    if(current.match(whitelist))
    {
        window.setTimeout(function(){document.location.reload(true)},1000*60);
        break;
    }   
}

but i get 6: ReferenceError: Can't find variable: whitelistURLPartials

this is in a safari extension if it matters.

EDIT:
It seems that Safari was keeping every version of the .js file from every changed version of the extension loaded. I had to restart Safari to clear them.

Grady Player
  • 14,399
  • 2
  • 48
  • 76
  • Can you paste in the code exactly as written? Are you sure that you've put the iterator in the same scope as the array? Did you check capitalization? – zzzzBov Jan 21 '13 at 19:07
  • I dont get this error on chrome http://jsfiddle.net/AWwbQ/ – Sajjan Sarkar Jan 21 '13 at 19:09
  • 1
    That code runs fine in my browser's JS console, so it's probably related to being a Safari extension. And FYI, using "for in" loops for array iteration is not recommended. Source: http://stackoverflow.com/questions/500504/javascript-for-in-with-arrays – mwcz Jan 21 '13 at 19:09
  • this is my entire code as written, thanks for checking for me... and @mwcz thanks for that info – Grady Player Jan 21 '13 at 19:10
  • mwcz, it looks like my usage of `for in` is safe, in this context, unless I don't really understand the problem with it. – Grady Player Jan 21 '13 at 19:12
  • Your use is safe, but not recommended, as mwcz said. Your `whitelist` var will be `"0"`, `"1"` (so, the indexes, as strings) - not what you expect, it seems. – bfavaretto Jan 21 '13 at 19:16
  • I mean, it's safe as long as `Array.prototype` has not been messed with. – bfavaretto Jan 21 '13 at 19:24

1 Answers1

2

Safari Had kept the old scripts in memory and running them every time my extension hit the domain that it was set to work on. I had to restart the Safari Process.

thanks to everyone who helped point me in the correct direction.

Grady Player
  • 14,399
  • 2
  • 48
  • 76