WP YouTube Lyte - Version 0.9.2

Version Description

  • solved bug with W3 Total Cache where the URL for lyte-min.js got broken (thanks to Serge of blogaf.org for reporting and helping figure this out)
  • some work on the bonus feature
Download this release

Release Info

Developer futtta
Plugin Icon 128x128 WP YouTube Lyte
Version 0.9.2
Comparing to
See all releases

Code changes from version 0.9.1 to 0.9.2

external/donottrack-min.js CHANGED
@@ -1 +1 @@
1
- function sanitizer(a){a=a.toLowerCase();for(x in spy){if(a.indexOf(spy[x])!==-1){a=true;break}}return a}var spy=["quantserve.com","media6degrees.com"];(function(){var _after=1;var _afterThrow=2;var _afterFinally=3;var _before=4;var _around=5;var _intro=6;var _regexEnabled=true;var _arguments="arguments";var _undef="undefined";var getType=function(){var a=Object.prototype.toString,b={},c={1:"element",3:"textnode",9:"document",11:"fragment"},d="Arguments Array Boolean Date Document Element Error Fragment Function NodeList Null Number Object RegExp String TextNode Undefined Window".split(" ");for(var e=d.length;e--;){var f=d[e],g=window[f];if(g){try{b[a.call(new g)]=f.toLowerCase()}catch(h){}}}return function(d){return d==null&&(d===undefined?_undef:"null")||d.nodeType&&c[d.nodeType]||typeof d.length=="number"&&(d.callee&&_arguments||d.alert&&"window"||d.item&&"nodelist")||b[a.call(d)]}}();var isFunc=function(a){return getType(a)=="function"};var weaveOne=function(source,method,advice){var old=source[method];if(advice.type!=_intro&&!isFunc(old)){var oldObject=old;old=function(){var code=arguments.length>0?_arguments+"[0]":"";for(var i=1;i<arguments.length;i++){code+=","+_arguments+"["+i+"]"}return eval("oldObject("+code+");")}}var aspect;if(advice.type==_after||advice.type==_afterThrow||advice.type==_afterFinally)aspect=function(){var a,b=null;try{a=old.apply(this,arguments)}catch(c){b=c}if(advice.type==_after)if(b==null)a=advice.value.apply(this,[a,method]);else throw b;else if(advice.type==_afterThrow&&b!=null)a=advice.value.apply(this,[b,method]);else if(advice.type==_afterFinally)a=advice.value.apply(this,[a,b,method]);return a};else if(advice.type==_before)aspect=function(){advice.value.apply(this,[arguments,method]);return old.apply(this,arguments)};else if(advice.type==_intro)aspect=function(){return advice.value.apply(this,arguments)};else if(advice.type==_around){aspect=function(){var a={object:this,args:Array.prototype.slice.call(arguments)};return advice.value.apply(a.object,[{arguments:a.args,method:method,proceed:function(){return old.apply(a.object,a.args)}}])}}aspect.unweave=function(){source[method]=old;pointcut=source=aspect=old=null};source[method]=aspect;return aspect};var search=function(a,b,c){var d=[];for(var e in a){var f=null;try{f=a[e]}catch(g){}if(f!=null&&e.match(b.method)&&isFunc(f))d[d.length]={source:a,method:e,advice:c}}return d};var weave=function(a,b){var c=typeof a.target.prototype!=_undef?a.target.prototype:a.target;var d=[];if(b.type!=_intro&&typeof c[a.method]==_undef){var e=search(a.target,a,b);if(e.length==0)e=search(c,a,b);for(var f in e)d[d.length]=weaveOne(e[f].source,e[f].method,e[f].advice)}else{d[0]=weaveOne(c,a.method,b)}return _regexEnabled?d:d[0]};aop={after:function(a,b){return weave(a,{type:_after,value:b})},afterThrow:function(a,b){return weave(a,{type:_afterThrow,value:b})},afterFinally:function(a,b){return weave(a,{type:_afterFinally,value:b})},before:function(a,b){return weave(a,{type:_before,value:b})},around:function(a,b){return weave(a,{type:_around,value:b})},introduction:function(a,b){return weave(a,{type:_intro,value:b})},setup:function(a){_regexEnabled=a.regexMatch}}})();head=document.getElementsByTagName("script")[0].parentNode;aop.around({target:head,method:"insertBefore"},function(a){if(typeof a.arguments[0].src==="string"&&a.arguments[0].type==="text/javascript"){if(sanitizer(a.arguments[0].src)===true){a.arguments[0].src="/wp-content/plugins/wp-youtube-lyte/external/false.js"}}return a.proceed()});var a2a_config=a2a_config||{};a2a_config.no_3p=1;var addthis_config={data_use_cookies:false};var _gaq=_gaq||[];_gaq.push(["_gat._anonymizeIp"])
1
+ function sanitizer(a){a=a.toLowerCase();for(x in spy){if(a.indexOf(spy[x])!==-1){a=true;break}}return a}var spy=["quantserve.com","media6degrees.com"];(function(){var _after=1;var _afterThrow=2;var _afterFinally=3;var _before=4;var _around=5;var _intro=6;var _regexEnabled=true;var _arguments="arguments";var _undef="undefined";var getType=function(){var a=Object.prototype.toString,b={},c={1:"element",3:"textnode",9:"document",11:"fragment"},d="Arguments Array Boolean Date Document Element Error Fragment Function NodeList Null Number Object RegExp String TextNode Undefined Window".split(" ");for(var e=d.length;e--;){var f=d[e],g=window[f];if(g){try{b[a.call(new g)]=f.toLowerCase()}catch(h){}}}return function(d){return d==null&&(d===undefined?_undef:"null")||d.nodeType&&c[d.nodeType]||typeof d.length=="number"&&(d.callee&&_arguments||d.alert&&"window"||d.item&&"nodelist")||b[a.call(d)]}}();var isFunc=function(a){return getType(a)=="function"};var weaveOne=function(source,method,advice){var old=source[method];if(advice.type!=_intro&&!isFunc(old)){var oldObject=old;old=function(){var code=arguments.length>0?_arguments+"[0]":"";for(var i=1;i<arguments.length;i++){code+=","+_arguments+"["+i+"]"}return eval("oldObject("+code+");")}}var aspect;if(advice.type==_after||advice.type==_afterThrow||advice.type==_afterFinally)aspect=function(){var a,b=null;try{a=old.apply(this,arguments)}catch(c){b=c}if(advice.type==_after)if(b==null)a=advice.value.apply(this,[a,method]);else throw b;else if(advice.type==_afterThrow&&b!=null)a=advice.value.apply(this,[b,method]);else if(advice.type==_afterFinally)a=advice.value.apply(this,[a,b,method]);return a};else if(advice.type==_before)aspect=function(){advice.value.apply(this,[arguments,method]);return old.apply(this,arguments)};else if(advice.type==_intro)aspect=function(){return advice.value.apply(this,arguments)};else if(advice.type==_around){aspect=function(){var a={object:this,args:Array.prototype.slice.call(arguments)};return advice.value.apply(a.object,[{arguments:a.args,method:method,proceed:function(){return old.apply(a.object,a.args)}}])}}aspect.unweave=function(){source[method]=old;pointcut=source=aspect=old=null};source[method]=aspect;return aspect};var search=function(a,b,c){var d=[];for(var e in a){var f=null;try{f=a[e]}catch(g){}if(f!=null&&e.match(b.method)&&isFunc(f))d[d.length]={source:a,method:e,advice:c}}return d};var weave=function(a,b){var c=typeof a.target.prototype!=_undef?a.target.prototype:a.target;var d=[];if(b.type!=_intro&&typeof c[a.method]==_undef){var e=search(a.target,a,b);if(e.length==0)e=search(c,a,b);for(var f in e)d[d.length]=weaveOne(e[f].source,e[f].method,e[f].advice)}else{d[0]=weaveOne(c,a.method,b)}return _regexEnabled?d:d[0]};aop={after:function(a,b){return weave(a,{type:_after,value:b})},afterThrow:function(a,b){return weave(a,{type:_afterThrow,value:b})},afterFinally:function(a,b){return weave(a,{type:_afterFinally,value:b})},before:function(a,b){return weave(a,{type:_before,value:b})},around:function(a,b){return weave(a,{type:_around,value:b})},introduction:function(a,b){return weave(a,{type:_intro,value:b})},setup:function(a){_regexEnabled=a.regexMatch}}})();scriptParent=document.getElementsByTagName("script")[0].parentNode;aop.around({target:scriptParent,method:"insertBefore"},function(a){if(typeof a.arguments[0].src==="string"&&(a.arguments[0].tagName.toLowerCase()==="script"||a.arguments[0].tagName.toLowerCase()==="img")){if(sanitizer(a.arguments[0].src)===true){a.arguments[0].src="javascript:void(0)"}}return a.proceed()});aop.around({target:document,method:"write"},function(a){a.arguments[0]=a.arguments[0].toLowerCase();if(a.arguments[0].indexOf("img")!==-1||a.arguments[0].indexOf("script")!==-1){if(sanitizer(a.arguments[0])===true){a.arguments[0]=a.arguments[0].replace(/</g,"<!-- ").replace(/>/g," -->")}return a.proceed()}});var a2a_config=a2a_config||{};a2a_config.no_3p=1;var addthis_config={data_use_cookies:false};var _gaq=_gaq||[];_gaq.push(["_gat._anonymizeIp"])
external/donottrack.js CHANGED
@@ -405,19 +405,31 @@ var spy=['quantserve.com','media6degrees.com'];
405
 
406
  })();
407
 
408
- head=document.getElementsByTagName('script')[0].parentNode;
409
-
410
- aop.around( {target: head, method: 'insertBefore'},
411
- function(invocation) {
412
- if ((typeof(invocation.arguments[0].src)==='string')&&(invocation.arguments[0].type==='text/javascript')) {
413
  if (sanitizer(invocation.arguments[0].src)===true){
414
- invocation.arguments[0].src='/wp-content/plugins/wp-youtube-lyte/external/false.js';
415
- }
416
  }
417
  return invocation.proceed();
418
  }
419
  );
420
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
  function sanitizer(tS) {
422
  tS=tS.toLowerCase();
423
  for (x in spy) {
405
 
406
  })();
407
 
408
+ scriptParent=document.getElementsByTagName('script')[0].parentNode;
409
+ aop.around( {target: scriptParent, method: 'insertBefore' },
410
+ function(invocation) {
411
+ if ((typeof(invocation.arguments[0].src)==='string')&&((invocation.arguments[0].tagName.toLowerCase()==='script')||(invocation.arguments[0].tagName.toLowerCase()==='img'))) {
 
412
  if (sanitizer(invocation.arguments[0].src)===true){
413
+ invocation.arguments[0].src='javascript:void(0)';
414
+ }
415
  }
416
  return invocation.proceed();
417
  }
418
  );
419
 
420
+ aop.around( {target: document, method: 'write' },
421
+ function(invocation) {
422
+ invocation.arguments[0]=invocation.arguments[0].toLowerCase();
423
+ if ((invocation.arguments[0].indexOf('img')!==-1)||(invocation.arguments[0].indexOf('script')!==-1)) {
424
+ if (sanitizer(invocation.arguments[0])===true) {
425
+ invocation.arguments[0]=invocation.arguments[0].replace(/</g,'<!-- ').replace(/>/g,' -->');
426
+ }
427
+ return invocation.proceed();
428
+ }
429
+ }
430
+ );
431
+
432
+
433
  function sanitizer(tS) {
434
  tS=tS.toLowerCase();
435
  for (x in spy) {
external/false.js DELETED
File without changes
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: futtta
3
  Tags: youtube, video, lyte, lite youtube embeds, html5 video, html5, widget, youtube audio, audio, playlist, youtube playlist, hd, performance, accessibility, sidebar
4
  Requires at least: 2.9
5
  Tested up to: 3.3
6
- Stable tag: 0.9.1
7
 
8
  "Lite YouTube Embeds" look like normal YouTube embeds but don't use Flash, thus reducing download size & page rendering time.
9
 
@@ -64,6 +64,10 @@ and you're good to go!
64
 
65
  == Changelog ==
66
 
 
 
 
 
67
  = 0.9.1 =
68
  * even better xhtml-compliancy
69
  * fixed readme.txt problems
3
  Tags: youtube, video, lyte, lite youtube embeds, html5 video, html5, widget, youtube audio, audio, playlist, youtube playlist, hd, performance, accessibility, sidebar
4
  Requires at least: 2.9
5
  Tested up to: 3.3
6
+ Stable tag: 0.9.2
7
 
8
  "Lite YouTube Embeds" look like normal YouTube embeds but don't use Flash, thus reducing download size & page rendering time.
9
 
64
 
65
  == Changelog ==
66
 
67
+ = 0.9.2 =
68
+ * solved bug with W3 Total Cache where the URL for lyte-min.js got broken (thanks to Serge of [blogaf.org](http://www.blogaf.org) for reporting and helping figure this out)
69
+ * some [work on the bonus feature](http://blog.futtta.be/2011/11/16/applying-javascript-aop-magic-to-stop-3rd-party-tracking-in-wordpress/)
70
+
71
  = 0.9.1 =
72
  * even better xhtml-compliancy
73
  * fixed readme.txt problems
widget.php CHANGED
@@ -37,7 +37,7 @@ class WYLWidget extends WP_Widget {
37
  <?php echo $before_widget; ?>
38
  <?php if ( $WYLtitle ) echo $before_title . $WYLtitle . $after_title; ?>
39
  <div class="lyte widget <?php echo $WYLaudio; ?>" id="<?php echo $WYLid; ?>" style="width:<?php echo $wSize[$WYLsize]['w']; ?>px;height:<?php if($WYLaudio==="audio") {echo "25";} else {echo $wSize[$WYLsize]['h'];} ?>px;"><noscript><a href="http://youtu.be/<?php echo $WYLid;?>"><img src="http://img.youtube.com/vi/<?php echo $WYLid; ?>/default.jpg" alt="" /></a></noscript><script type="text/javascript"><!--
40
- var bU='<?php echo $lyteSettings['path'];?>';var d=document;if(d.addEventListener){d.addEventListener('DOMContentLoaded', insert, false)}else{window.onload=insert} function insert(){if(!d.getElementById('lytescr')){lytescr=d.createElement('script');lytescr.async=true;lytescr.id='lytescr';lytescr.src='<?php echo $lyteSettings['path']."lyte-min.js?".$wyl_version;?>';h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(lytescr, h)}};
41
  --></script></div>
42
  <div><?php echo $WYLtext ?></div>
43
  <?php echo $after_widget; ?>
37
  <?php echo $before_widget; ?>
38
  <?php if ( $WYLtitle ) echo $before_title . $WYLtitle . $after_title; ?>
39
  <div class="lyte widget <?php echo $WYLaudio; ?>" id="<?php echo $WYLid; ?>" style="width:<?php echo $wSize[$WYLsize]['w']; ?>px;height:<?php if($WYLaudio==="audio") {echo "25";} else {echo $wSize[$WYLsize]['h'];} ?>px;"><noscript><a href="http://youtu.be/<?php echo $WYLid;?>"><img src="http://img.youtube.com/vi/<?php echo $WYLid; ?>/default.jpg" alt="" /></a></noscript><script type="text/javascript"><!--
40
+ var bU='<?php echo $lyteSettings['path'];?>';var d=document;if(d.addEventListener){d.addEventListener('DOMContentLoaded', insert, false)}else{window.onload=insert} function insert(){if(!d.getElementById('lytescr')){lytescr=d.createElement('script');lytescr.async=true;lytescr.id='lytescr';lytescr.src='<?php echo $lyteSettings['path']."lyte-min.js?wylver=".$wyl_version;?>';h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(lytescr, h)}};
41
  --></script></div>
42
  <div><?php echo $WYLtext ?></div>
43
  <?php echo $after_widget; ?>
wp-youtube-lyte.php CHANGED
@@ -4,13 +4,13 @@ Plugin Name: WP YouTube Lyte
4
  Plugin URI: http://blog.futtta.be/tag/lyte
5
  Description: Lite and accessible YouTube audio and video embedding.
6
  Author: Frank Goossens (futtta)
7
- Version: 0.9.1
8
  Author URI: http://blog.futtta.be/
9
  Text Domain: wp-youtube-lyte
10
  Domain Path: /languages
11
  */
12
 
13
- $wyl_version="0.9.0";
14
 
15
  $plugin_dir = basename(dirname(__FILE__)).'/languages';
16
  load_plugin_textdomain( 'wp-youtube-lyte', null, $plugin_dir );
@@ -112,7 +112,7 @@ function lyte_parse($the_content) {
112
  $noscript="<noscript><a href=\"http://youtu.be/".$vid."\"><img src=\"http://img.youtube.com/vi/".$vid."/0.jpg\" alt=\"\" width=\"".$lyteSettings[2]."\" height=\"".$divHeight."\" />".$noscript_post."</a></noscript>";
113
  }
114
 
115
- $lytetemplate = "<div class=\"lyte".$audioClass.$hidefClass.$plClass."\" id=\"WYL_".$vid."\" style=\"width:".$lyteSettings[2]."px;height:".$divHeight."px;\">".$noscript."<script type=\"text/javascript\"><!-- \n var bU='".$lyteSettings['path']."';var d=document;if(d.addEventListener){d.addEventListener('DOMContentLoaded', insert, false)}else{window.onload=insert} function insert(){if(!d.getElementById('lytescr')){lytescr=d.createElement('script');lytescr.async=true;lytescr.id='lytescr';lytescr.src='".$lyteSettings['path']."lyte-min.js?".$lyteSettings['version']."';h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(lytescr, h)}}; \n --></script></div>".$lytelinks_txt;
116
  $the_content = preg_replace("/(<p>)?http(v|a):\/\/([a-zA-Z0-9\-\_]+\.|)(youtube|youtu)(\.com|\.be)\/(((watch(\?v\=|\/v\/)|)([a-zA-Z0-9\-\_]{11}))|(playlist\?list\=PL([a-zA-Z0-9\-\_]{16})))([^\s<]*)(<\/p>)?/", $lytetemplate, $the_content, 1);
117
  }
118
  }
4
  Plugin URI: http://blog.futtta.be/tag/lyte
5
  Description: Lite and accessible YouTube audio and video embedding.
6
  Author: Frank Goossens (futtta)
7
+ Version: 0.9.2
8
  Author URI: http://blog.futtta.be/
9
  Text Domain: wp-youtube-lyte
10
  Domain Path: /languages
11
  */
12
 
13
+ $wyl_version="0.9.2";
14
 
15
  $plugin_dir = basename(dirname(__FILE__)).'/languages';
16
  load_plugin_textdomain( 'wp-youtube-lyte', null, $plugin_dir );
112
  $noscript="<noscript><a href=\"http://youtu.be/".$vid."\"><img src=\"http://img.youtube.com/vi/".$vid."/0.jpg\" alt=\"\" width=\"".$lyteSettings[2]."\" height=\"".$divHeight."\" />".$noscript_post."</a></noscript>";
113
  }
114
 
115
+ $lytetemplate = "<div class=\"lyte".$audioClass.$hidefClass.$plClass."\" id=\"WYL_".$vid."\" style=\"width:".$lyteSettings[2]."px;height:".$divHeight."px;\">".$noscript."<script type=\"text/javascript\"><!-- \n var bU='".$lyteSettings['path']."';var d=document;if(d.addEventListener){d.addEventListener('DOMContentLoaded', insert, false)}else{window.onload=insert} function insert(){if(!d.getElementById('lytescr')){lytescr=d.createElement('script');lytescr.async=true;lytescr.id='lytescr';lytescr.src='".$lyteSettings['path']."lyte-min.js?wylver=".$lyteSettings['version']."';h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(lytescr, h)}}; \n --></script></div>".$lytelinks_txt;
116
  $the_content = preg_replace("/(<p>)?http(v|a):\/\/([a-zA-Z0-9\-\_]+\.|)(youtube|youtu)(\.com|\.be)\/(((watch(\?v\=|\/v\/)|)([a-zA-Z0-9\-\_]{11}))|(playlist\?list\=PL([a-zA-Z0-9\-\_]{16})))([^\s<]*)(<\/p>)?/", $lytetemplate, $the_content, 1);
117
  }
118
  }