From 3ed3c272774f2525c68ae2a566dc2146c8065716 Mon Sep 17 00:00:00 2001 From: gorhill Date: Sun, 13 Mar 2016 13:11:14 -0400 Subject: [PATCH] #1461: hardened experimental scriplet --- assets/checksums.txt | 2 +- assets/ublock/resources.txt | 47 +++++++++++++++++++++++++++++-------- 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/assets/checksums.txt b/assets/checksums.txt index 1677808c3..e4bd76fde 100644 --- a/assets/checksums.txt +++ b/assets/checksums.txt @@ -5,7 +5,7 @@ dcc881135f01d1e264c2be59a8aaa1e0 assets/ublock/filters.txt 98088252cedafb8571cf61b91bea219e assets/ublock/badware.txt 5baa90e2da7cd6a73edff2010557ee57 assets/ublock/redirect.txt b65ec581214a0d24dad6522a60f827ab assets/ublock/experimental.txt -36418463fe1f706e56e8f74371d1c12c assets/ublock/resources.txt +5ee3e1aa589018d7abf5978306e2c018 assets/ublock/resources.txt 059e0bfbf22bd242dda7b07389fe09a2 assets/ublock/filter-lists.json 3605c73f21abca428c7eb69a8bc32dfe assets/thirdparties/easylist-downloads.adblockplus.org/easyprivacy.txt a91af77c47c302c0741c7445b0fada1a assets/thirdparties/easylist-downloads.adblockplus.org/easylist.txt diff --git a/assets/ublock/resources.txt b/assets/ublock/resources.txt index 66e40c519..63a1f1e30 100644 --- a/assets/ublock/resources.txt +++ b/assets/ublock/resources.txt @@ -830,23 +830,50 @@ disqus.com/embed.js application/javascript ytad-defuser.js application/javascript (function() { var ytp, ytpc; - Object.defineProperty(window, 'ytplayer', { - get: function() { - return ytp; - }, - set: function(a) { - ytp = a; + var trapytpca = function() { + if ( ytpc && ytpc.args && typeof ytpc.args.ad_slots === 'string' ) { + ytpc.args.ad_slots = ytpc.args.ad_slots.replace(/^0+(,|$)/, ''); + } + }; + var trapytpc = function() { + ytpc = ytp.config; + if ( ytpc ) { + trapytpca(); + return; + } + try { Object.defineProperty(ytp, 'config', { get: function() { return ytpc; }, set: function(a) { ytpc = a; - if ( a && a.args && typeof a.args.ad_slots === 'string' ) { - a.args.ad_slots = a.args.ad_slots.replace(/^0+(,|$)/, ''); + trapytpca(); + } + }); + } catch (ex) { + } + }; + var trapytp = function() { + ytp = window.ytplayer; + if ( ytp ) { + trapytpc(); + return; + } + try { + Object.defineProperty(window, 'ytplayer', { + get: function() { + return ytp; + }, + set: function(a) { + ytp = a; + if ( !a.config ) { + trapytpc(); } } }); - } - }); + } catch (ex) { + } + }; + trapytp(); })();