gregersrygg / craploader Goto Github PK
View Code? Open in Web Editor NEWAsynchronous script loader/runner for ads, widgets and other third-party content
Asynchronous script loader/runner for ads, widgets and other third-party content
How can I load two different adsense ads on the same page? Shall the variables be handledd outside craploader and then load the .js to a id with craploader?
With AdTech as our main ad provider we are having issues with multiple calls within the same page. The call to AdTech has a parameter for the creative size - for instance 225 for a 728x90, 170 for a 300x250.
If the first call on the page is a 300x250 and the second one a 728x90, we end up with two 300x250 ads, with one of them ending up in the container for the 728x90 ad. And I'm unable to figure out yet why this is happening.
I can provide you with a test page but I can't post the calls here publicly. If you want, I can mail you the test page. My email: peter dot lorent and it is a gmail account.
Otherwise, you can maybe give me some pointers where I should start looking in the craploader script.
The getElementByIdReplacement checks the buffer and returns a fake element when the script needs this, but the element is never injected to the document. So if a script modifies the element, those changes are lost.
I've found yet another crappy ad with a script tag that does not exist at the top-level but inside another tag.
Test case:
<!DOCTYPE html>
<html>
<body>
<div id="placeholder"></div>
<script src="/clientscripts/crapLoader.js"></script>
<script>crapLoader.loadScript('./crap-ad.js', 'placeholder');</script>
</body>
</html>
crap-ad.js:
document.write('<div><scr'+'ipt>var x = 1;</scr'+'ipt><span>HTML</span><'+'/div>');
The correct output (without crapLoader) is:
<div><span>HTML</span></div>
With crapLoader the result is:
<div></div><span>HTML</span>
The "split" function works fine (with support.splitWithCapturingParentheses = true):
["<div>", "<script>var x = 1;</script>", "<span>HTML</span></div>"]
The problem seems to be that later in the function "checkWriteBuffer" the HTML fragments are written to the document independently. I do not yet have an idea how to fix this issue.
[Btw, with support.splitWithCapturingParentheses = false the split does not work correctly, but that's another bug that is independent from this issue here:]
["<script>var x = 1;</script>", "<span>HTML</span></div>"]
I made this simple script for banner reload.
http://wiinigo.hol.es/banner.php
First time that you click in link (Click to Load!) works well but when script runs second time in Internet Explorer doesn`t work.
Any idea?
Thanks.
The following test-case fails (empty output). It succeeds (output "success") when crapLoader is disabled.
<!DOCTYPE html>
<html>
<body>
<script src="crapLoader.js"></script>
<script>
crapLoader.hijack({
debug: true,
parallel: false
});
</script>
<script>
document.write('<sc'+'ript type=\"text\/javasc'+'ript\">');
document.write('document.write(\'<div id=\"myid\"><\/div>\');');
document.write('var mydiv = document.getElementById(\"myid\");');
document.write('mydiv.innerHTML = "success";');
document.write('<\/sc'+'ript>');
</script>
</body>
</html>
The JavaScript in the last <script> tag is a reduced test-case of a real-world JavaScript ad. I have no influence on the code and know that it is crap. But I guess that is exactly what crapLoader is about. ;-)
Tested Browsers: Chrome 20, Firefox 14
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.