Archive for the ‘wordpress’ tag
It’s official: you can not track your visitors
After almost a year of tinkering with my Donottrack-plugin for WordPress, I’ve requested it to be hosted in the WordPress repositories and uploaded version 0.1.0. So if you’re using Donottrack on your blog, or if you activated this “bonus feature” of WP YouTube Lyte, I propose you give WP DoNotTrack a try and let me know what gives here in the comments or via the contact form?
From the readme:
WP DoNotTrack stops plugins and themes from adding 3rd party tracking code to your blog to protect your visitor’s privacy. WP DoNotTrack uses (a slightly modified) version of jQuery AOP to catch and inspect elements that are about to be added to the DOM and renders these harmless if the black- or whitelist says so.
The current version is blacklist-based and stops tracking by media6degrees and quantserve. This can easily be changed in the javascript though. Future versions will include a WordPress admin-page to change these settings.
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?
WP YouTube Lyte 0.9.0: size matters
I uploaded a new version of WP YouTube Lyte to the WordPress SVN repository earlier today. The markdown parser seems to be in a bad mood today and the changes in the readme.txt (the changelog, first and foremost) aren’t visible, so here’s what’s new in this release:
- you can now change player size from the default one (as proposed by Edward Owen); httpv://www.youtube.com/watch?v=_SQkWbRublY#stepSize=-2 or httpv://youtu.be/_SQkWbRublY#stepSize=+1 will change player size to one of the other available sizes in your choosen format (4:3 or 16:9)
- added a smaller 16:9 size and re-arranged player sizes on the options-screen
- Bugfix: changed lyte-div ID to force it to be xhtml-compliant (ID’s can’t start with a digit, hat tip: Ruben of ytuquelees.net
- Bugfix: added version in js-call to avoid caching issues (lyte-min.js?ver=0.8.1) as experienced by some users and reported by Ryan of givemeshred.com
- Upgrade to the “bonus feature” to fix things (consider this beta though)
- Languages: added Hebrew (by Sagive SEO) and Catalan (by Ruben of ytuquelees.net) translations and added completed Spanish version (thanks to Paulino Brener from Social Media Travelers)
- tested succesfully on WordPress 3.3 (beta 2)
The (slightly smaller) lyte-embedded YouTube video to go with this release: “She wants” by Metronomy (very Japan-esque by the way):
As always, your feedback is welcome in the comments or via the contact form!
WP Privacy: Quantcast sneaks back in
After almost a year of peace and quiet, Quantcast tracking code has returned to this blog. As reported by Brian Yang, the stupid hack that stopped the code from being included doesn’t work any more. Automattic recently switched to the new Quantcast-code, which instead of using the old-fashioned document.write now gets inserted asynchronously by a DOM-method (insertBefore). I’m looking at ways to stop this from happening or at least limit it one way or the other, but for the time being there’s no fix. Bear with me and do speak up (in the comments below of via the contact form) if you think you can help!
WP YouTube Lyte; support for playlists (almost) included
Work on the next version of WP YouTube Lyte is almost finished. The main new features you can expect in version 0.8.0 are:
- support for playlists
- support for HD video (if size of the embedded player is big enough)
- updated UI elements & player sizes to match new, dark YouTube player style
- removed support for legacy YouTube embed code
Embedding a playlist will be as simple as adding
httpv://www.youtube.com/playlist?list=<playlist_id>.
The result will look like this documentary about Arcade Fire (4 video’s in one playlist):
Now off to testing this blogpost with an embedded playlist in all browsers I can get my hands on. Your feedback (off course) is always welcome as well! If all goes as planned I’ll push 0.8.0 to the wordpress svn later this week.
WP YouTu.be Lyte: a minor release & some meandering thoughts
Yesterday I pushed WP YouTube Lyte 0.7.3 out the gates. The main trigger for that new release was a bug report about the plugin not behaving as expected when using the youtu.be-links that you get when clicking the “share”-button on YouTube. Being from that TLD mysself I could not but fix this; the new version recognizes and parses both httpv://youtube.com/watch?v=videoid and httpv://youtu.be/videoid links in posts, pages and widgets. Other features: Slovenian translation (thanks Mitja Mihelič @arnes.si) and a small change to the donottrack-inclusion to make it work over https (hat tip; Chris @ campino2k.de).
Speaking of donottrack: I’ve finally started rewriting that privacy-enhancing plugin. It might … No, it WILL take some time, but expect a whitelist-based approach where you’ll be able to get a report of all inclusions of external content (images, css, javascript, …) in your site and where you can just tick a checkbox per domain you want to allow. All other current and future domains that rogue plugins try to smuggle in after you configured, will be stopped. Next to document.write’s I hope to be able to catch innerHTML and DOM methods like insertBefore and appendChild. If you’re a javascript DOM magician, I could sure use your help on those!
Not sure where I’ll be going with WP YouTube Lyte, it feels pretty complete to me. Stuff that might be added at a later stage;
- update of the player GUI to match the style of the new darker YouTube embeds
- support for the embedded YouTube playlists player
- catching the end of video playing and killing it (well, removing it from the DOM, gently yet firmly)
- adding translations (you’re welcome to participate, if you’re not familiar with GetText I can put all strings up in a Google spreadsheet)
Do comment below or contact me if you have other feature requests though! And thanks for all the downloads (36.000 and counting)!!
And as is traditional of WP YouTube Lyte announcements, here’s a small video to celebrate the new release; Intergalactic Lovers, a Belgian band, playing “Delay” live.
Quick & dirty “CDN” in WordPress
If you want a quick & dirty way to speed up WordPress without any plugins:
- create a subdomain in DNS, e.g. static.yourblog.org
- add that subdomain as a ServerAlias to your Apache config (remember to restart apache)
- add the following to your wp-config.php:
define('WP_CONTENT_URL','http://static.yourblog.org/wp-content');
If you want to do this the right way; plugins such as WP Super Cache or W3 Total Cache do a much better job at this.


