aboutsummaryrefslogtreecommitdiffstats
path: root/src/js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js')
-rw-r--r--src/js/assets.js4
-rw-r--r--src/js/element-picker.js7
-rw-r--r--src/js/js-loader.js39
-rw-r--r--src/js/sitepatch-safari.js5
-rw-r--r--src/js/vapi-appinfo.js2
-rw-r--r--src/js/vapi-client.js16
6 files changed, 21 insertions, 52 deletions
diff --git a/src/js/assets.js b/src/js/assets.js
index 83b07e8..737dea6 100644
--- a/src/js/assets.js
+++ b/src/js/assets.js
@@ -229,7 +229,9 @@ var cachedAssetsManager = (function() {
var getTextFileFromURL = function(url, onLoad, onError) {
// https://github.com/gorhill/uMatrix/issues/15
var onResponseReceived = function() {
- if ( typeof this.status === 'number' && this.status >= 200 && this.status < 300 ) {
+ // xhr for local files gives status 0, but actually succeeds
+ if ( this.status >= 200 && this.status < 300
+ || this.status === 0 && this.responseText ) {
return onLoad.call(this);
}
return onError.call(this);
diff --git a/src/js/element-picker.js b/src/js/element-picker.js
index fa29f6a..9cf4a32 100644
--- a/src/js/element-picker.js
+++ b/src/js/element-picker.js
@@ -120,6 +120,11 @@
/******************************************************************************/
+// don't run in frames
+if (window.top !== window) {
+ return;
+}
+
// https://github.com/gorhill/uBlock/issues/314#issuecomment-58878112
// Using an id makes uBlock's CSS rules more specific, thus prevents
// surrounding external rules from winning over own rules.
@@ -874,7 +879,7 @@ var startPicker = function(details) {
].join('');
pickerRoot.appendChild(divDialog);
- // https://github.com/gorhill/uBlock/issues/344#issuecomment-60775958
+ // https://github.com/gorhill/uBlock/issues/344#issuecomment-60775958
// Insert in `html` tag, not `body` tag.
document.documentElement.appendChild(pickerRoot);
svgRoot.addEventListener('click', onSvgClicked);
diff --git a/src/js/js-loader.js b/src/js/js-loader.js
deleted file mode 100644
index cd60baa..0000000
--- a/src/js/js-loader.js
+++ /dev/null
@@ -1,39 +0,0 @@
-(function() {
- 'use strict';
-
- document.body.style.display = "none";
- document.addEventListener("DOMContentLoaded", function onDOMReady(e) {
- document.removeEventListener(e.type, onDOMReady, false);
-
- var jsListToLoad = document.querySelector("script[data-jsList]");
-
- if (jsListToLoad) {
- jsListToLoad = jsListToLoad.getAttribute("data-jsList").trim().split(/\s+/);
- }
-
- if (Array.isArray(jsListToLoad)) {
- var loadNextJSFile = function() {
- var script, src = jsListToLoad.shift();
-
- if (src) {
- script = document.createElement("script");
- script.onload = function() {
- this.onload = null;
-
- if (jsListToLoad.length) {
- loadNextJSFile();
- }
- else {
- document.body.style.display = "";
- jsListToLoad = document.querySelector("script[data-jsList]");
- jsListToLoad.parentNode.removeChild(jsListToLoad);
- }
- };
- document.body.appendChild(script).src = src;
- }
- };
-
- loadNextJSFile();
- }
- }, false);
-})(); \ No newline at end of file
diff --git a/src/js/sitepatch-safari.js b/src/js/sitepatch-safari.js
index e4eee90..4c4e9f6 100644
--- a/src/js/sitepatch-safari.js
+++ b/src/js/sitepatch-safari.js
@@ -9,7 +9,7 @@ self.vAPI = self.vAPI || {};
if (/^www\.youtube(-nocookie)?\.com/.test(location.host)) {
vAPI.sitePatch = function() {
- window.addEventListener('load', function onWindowLoad() {
+ var onWindowLoad = function() {
this.removeEventListener('load', onWindowLoad, true);
var spf = this._spf_state;
@@ -19,7 +19,8 @@ if (/^www\.youtube(-nocookie)?\.com/.test(location.host)) {
window.location.href = url;
};
}
- }, true);
+ };
+ window.addEventListener('load', onWindowLoad, true);
// based on ExtendTube's ad removing solution
diff --git a/src/js/vapi-appinfo.js b/src/js/vapi-appinfo.js
index 2dea72c..372fc04 100644
--- a/src/js/vapi-appinfo.js
+++ b/src/js/vapi-appinfo.js
@@ -5,6 +5,6 @@ self.vAPI = self.vAPI || {};
vAPI.app = {
/**/name: 'µBlock',
- /**/version: '0.7.0.7',
+ /**/version: '0.7.0.9',
/**/url: 'https://github.com/gorhill/uBlock',
}; \ No newline at end of file
diff --git a/src/js/vapi-client.js b/src/js/vapi-client.js
index 071f813..51d7311 100644
--- a/src/js/vapi-client.js
+++ b/src/js/vapi-client.js
@@ -74,14 +74,14 @@ if (self.chrome) {
return;
}
- if (!this.listenerId) {
- this.setup();
- }
-
this.channels[name] = {
portName: name,
listener: typeof callback === 'function' ? callback : null,
send: function(message, callback) {
+ if (!vAPI.messaging.listenerId) {
+ vAPI.messaging.setup();
+ }
+
message = {
portName: this.portName,
msg: message
@@ -137,14 +137,14 @@ if (self.chrome) {
return;
}
- if (!this._connector) {
- this.setup();
- }
-
this.channels[name] = {
portName: name,
listener: typeof callback === 'function' ? callback : null,
send: function(message, callback) {
+ if (!vAPI.messaging._connector) {
+ vAPI.messaging.setup();
+ }
+
message = {
portName: this.portName,
msg: message