1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-04 18:19:38 +02:00
uBlock/platform/safari/sitepatch-safari.js

112 lines
3.3 KiB
JavaScript
Raw Normal View History

/*******************************************************************************
2015-01-28 06:39:55 +01:00
µBlock - a browser extension to block requests.
Copyright (C) 2014 The µBlock authors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see {http://www.gnu.org/licenses/}.
Home: https://github.com/gorhill/uBlock
*/
2015-01-25 08:43:39 +01:00
var vAPI = self.vAPI = self.vAPI || {};
2015-01-27 20:36:19 +01:00
vAPI.sitePatch = function() {
(function() {
2015-01-27 20:36:19 +01:00
// disable spf
window.ytspf = {};
Object.defineProperty(window.ytspf, "enabled", {
2015-01-28 06:39:55 +01:00
"value": false
});
2015-01-27 20:36:19 +01:00
// Based on ExtendTube's ad removing solution
var p;
var yt = {};
var config_ = {};
var ytplayer = {};
2015-01-28 06:39:55 +01:00
var playerConfig = {
args: {}
};
2015-01-27 20:36:19 +01:00
Object.defineProperties(yt, {
2015-01-28 06:39:55 +01:00
"playerConfig": {
get: function() {
return playerConfig;
},
2015-01-27 20:36:19 +01:00
set: function(data) {
2015-01-28 06:39:55 +01:00
if(data && typeof data === "object" && data.args && typeof data.args === "object") {
2015-01-27 20:36:19 +01:00
var nope = /ad\d?_|afv|watermark|adsense|xfp/;
2015-01-28 06:39:55 +01:00
for(var prop in data.args) {
if(nope.test(prop) && !/policy/.test(prop)) {
2015-01-27 20:36:19 +01:00
delete data.args[prop];
}
}
}
2015-01-27 20:36:19 +01:00
playerConfig = data;
2015-01-28 06:39:55 +01:00
var playerRoot = document.querySelector("[data-swf-config]");
if(playerRoot) {
2015-01-27 20:36:19 +01:00
playerRoot.dataset.swfConfig = JSON.stringify(yt.playerConfig);
}
}
},
2015-01-28 06:39:55 +01:00
"config_": {
get: function() {
return config_;
},
set: function(value) {
config_ = value;
}
}
2015-01-27 20:36:19 +01:00
});
2015-01-28 06:39:55 +01:00
Object.defineProperty(config_, "PLAYER_CONFIG", {
get: function() {
return yt.playerConfig;
},
set: function(value) {
yt.playerConfig = value;
}
2015-01-27 20:36:19 +01:00
});
2015-01-28 06:39:55 +01:00
Object.defineProperty(ytplayer, "config", {
get: function() {
return playerConfig;
},
set: function(value) {
yt.playerConfig = value;
}
2015-01-27 20:36:19 +01:00
});
2015-01-28 06:39:55 +01:00
if(window.yt) {
var oldyt = window.yt;
delete window.yt;
for(p in oldyt) {
yt[p] = oldyt[p];
}
}
Object.defineProperty(window, "yt", {
get: function() {
return yt;
},
set: function() {}
});
if(window.ytplayer) {
var oldytplayer = window.ytplayer.config;
delete window.ytplayer;
for(p in oldytplayer) {
ytplayer.config[p] = oldytplayer[p];
}
}
2015-01-28 06:39:55 +01:00
Object.defineProperty(window, "ytplayer", {
get: function() {
return ytplayer;
},
2015-01-27 20:36:19 +01:00
set: function() {}
});
})();
2015-01-27 20:36:19 +01:00
};