0

I've search for a long time and i didn't found the answer for my problem. The thing is i have an addon that can insert JS into any site, and my task is to verify if the script has loaded, retrive it's src and it parameters depending on domein and alert() them.

Example script src looks like this:

<script src="https://example.com/tags?id={FOO}_{BAR}_{VARIOUS_THINGS}_{ID},{ID},{ID}"></script>

I tried to use some snippets form here Verify External Script Is Loaded, especially this one, which i altered a bit with timeout and other stuff:

window.onload = function(){ setTimeout( function(){
var foo = $('script[src*="example.com"]').length;
if (foo === 0) 
    {
    alert('no script here');
    }
else {
    alert('Yay! script is here!');
    }
}, 2500); };

But it only checks if script is there and if foo matches the string that i gave, and i would want to check also what are the parameters, so i tried to alter this $('script[src*="example.com"]') to things that I normally get in {VARIOUS_THINGS} macro, let's say these are "boogie1", "chewingGum" and "PinkFlamingo". They work, for example when I change "example.com" to "PinkFlamingo" it only detects "PinkFlamingo" but not the "boogie1" or other macros. I tried to put * in there so it would take whole example.com* but id doesn't work either.

Basically i don't know how to set the conditions that it would take whole src when given a domain, and retrive and alert some variable in the script src {VARIOUS_THINGS} and return only matching one (not true/false statement). I also tried getElementByTagName and currentScript but i did not manage to do anything that works...

sf_
  • 1,138
  • 2
  • 13
  • 28
zombeck
  • 3
  • 2

0 Answers0