Monthly Archives: November 2011

Hug a Blogger Day!

Gelezen bij Jan Seurinck; Flattr organiseert de “Pay a Blogger Day”. Maar ik moet geen geld voor m’n blog, niet via zo’n micropayments-knop en niet door middel van advertenties. M’n blog (en m’n WordPress plugins), dat is mijn 5 minutes of fame. Of dan toch de long tail versie; een heel klein beetje fame, verspreid over een schijnbaar eindeloos uitgerekte 5 minuten.

Geef uw geld dus gerust aan een goed doel, of ga er eens lekker mee eten, uw aandacht volstaat ruimschoots om de boel hier draaiende te houden. Maar ge moogt altijd “hallo” zeggen in de comments, bloggers hebben dat zo graag dat ze er speciaal een blogpost voor schrijven!

Javascript tip: visualizing DOM events

At work we were stumped by a simple link that upon clicking didn’t have the browser request the target page. Our supplier investigated using VisualEvent, a bookmarklet-initiated javasript-tool that goes through a page and visualizes all events on DOM nodes. The developer released VisualEvent 2 a couple of days ago (also on GitHub), which I played around with for a bit and it really is great for debugging purposes!

The culprit for the “broken” link by the way was a bug in an old version of SmoothScroll, a jQuery-plugin by fellow Belgian Mathias Bynens which ensures smooth scrolling when clicking on a in-page link. The plugin did check if the link was to an anchor on the same page, but it had already prevented the default action before that check was made, resulting in the broken link. The current version of the plugin does the check before the default action is prevented, so all is well, your weekend can start. Enjoy!

As found on the web (November 23rd)

youtube (feed #51)
blog (feed #46)
generic (feed #49)
generic (feed #49)
generic (feed #49)
generic (feed #49)
generic (feed #49)
youtube (feed #51)
youtube (feed #51)

Applying Javascript AOP-magic to stop 3rd party tracking in WordPress

It was always my intention to elaborate on my small donottrack plugin for WordPress, but it was only when Automattic upgraded to the new asynchronous Quantcast code that I was forced to look actually dig in.

The new Quantcast-code doesn’t use the old-fashioned document.write, but inserts the javascript asynchronously with an insertBefore on the parent of the first script-node (as popularized by the asynchronous Google Analytics-code). Variations on this method would include e.g. using appendChild or adding it to head (although that might not exist).

A couple of months ago I experimented with the DomNodeInserted event, but that isn’t supported by all browsers. And even when it works, I found no consistent way to stop the tracking script (which was already added to the DOM, as the event is triggered after) from being loaded or executed. But last week while searching for a better solution I found a reference to javascript AOP on StackOverflow and after following some links I discovered the JQuery AOP-plugin.

JQuery AOP allows one to (amongst other things) add an advice around a method. When the method is called, the advice kicks in before the execution. The advice is a function which can investigate and change the parameters used by the method. And that’s exactly what the current version of DoNotTrack does; it has AOP.around (I’ve removed the JQuery dependency) catch insertBefore and appendChild, investigates the src-attribute and replaces that value if it points to quantserve.com before allowing the method execution to proceed.

scriptParent=document.getElementsByTagName('script')[0].parentNode;

aop.around( {target: scriptParent, method: /[insertBefore|appendChild]/},
        function(invocation) {
                if ((typeof(invocation.arguments[0].src)==='string')&&((invocation.arguments[0].tagName.toLowerCase()==='script')||(invocation.arguments[0].tagName.toLowerCase()==='img'))) {
                        if (sanitizer(invocation.arguments[0].src)===true){
                             invocation.arguments[0].src='javascript:return false;';
                        }
                }
                return invocation.proceed();
        }
);

I’m working on a more generic version of an AOP-based WordPress Privacy plugin now. In a first stage it will probably be based on a blacklist, that is editable in the WP Privacy options-screen but at a later date a whitelist-based approach will be added (based on an integration with webpagetest.org). Let’s add that to my New Years resolution for 2012, shall we?

As found on the web (November 16th)

generic (feed #49)
generic (feed #49)
youtube (feed #51)
generic (feed #49)
blog (feed #46)
generic (feed #49)
youtube (feed #51)
frank liked 2 videos.
generic (feed #49)
youtube (feed #51)
frank liked 3 videos.
facebook (feed #40)
frank Facebook-Syndizierungsfehler.
generic (feed #49)
generic (feed #49)
generic (feed #49)
generic (feed #49)
youtube (feed #51)