Iterate Scripts

In developing user scripts, the developer often iterate through the page for embedded javascript codes. Under the IEScripts environment, there should be a problem, the iterated script contains the user script itself. There are tricks to avoid this problem, by identifing which segment code is the user script.

The next example is in user script "video download", in which the iterate can really find itself. A simple method is to identify the IEScripts with delimiter "==UserScript==".

var scriptmedia=document.getElementsByTagName('script'); for(i=0;i<scriptmedia.length;++i) { if(scriptmedia[i].text.indexOf('==UserScript==') != -1) continue; //do something here }

Code Example: DownloadVideo.ieuser.js