aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorgorhill <rhill@raymondhill.net>2015-09-30 09:33:38 -0400
committergorhill <rhill@raymondhill.net>2015-09-30 09:33:38 -0400
commit8d294869fe252b54c08a14fc9b94722c2ace56ef (patch)
tree4b7e65aa6271d10c111cd138ac84cc2ef61643b9 /src
parentcc17a77b0ac69ba73299148e2a710dcbd5069a21 (diff)
downloaduBlock-8d294869fe252b54c08a14fc9b94722c2ace56ef.zip
uBlock-8d294869fe252b54c08a14fc9b94722c2ace56ef.tar.gz
uBlock-8d294869fe252b54c08a14fc9b94722c2ace56ef.tar.bz2
this fixes #756
Diffstat (limited to 'src')
-rw-r--r--src/background.html1
-rw-r--r--src/js/contentscript-start.js13
-rw-r--r--src/js/cosmetic-filtering.js17
3 files changed, 11 insertions, 20 deletions
diff --git a/src/background.html b/src/background.html
index 5852880..43863d2 100644
--- a/src/background.html
+++ b/src/background.html
@@ -30,6 +30,7 @@
<script src="js/traffic.js"></script>
<script src="js/contextmenu.js"></script>
<script src="js/reverselookup.js"></script>
+<script src="js/rpcreceiver.js"></script>
<script src="js/start.js"></script>
</body>
</html>
diff --git a/src/js/contentscript-start.js b/src/js/contentscript-start.js
index 6397a1e..b4a2b04 100644
--- a/src/js/contentscript-start.js
+++ b/src/js/contentscript-start.js
@@ -128,15 +128,7 @@ var netFilters = function(details) {
//console.debug('document.querySelectorAll("%s") = %o', text, document.querySelectorAll(text));
};
-var onBeforeScriptExecuteHandler = function(ev) {
- if ( vAPI.reScriptTagRegex.test(ev.target.textContent) ) {
- ev.preventDefault();
- ev.stopPropagation();
- }
-};
-
var filteringHandler = function(details) {
- var value;
var styleTagCount = vAPI.styles.length;
vAPI.skipCosmeticFiltering = !details || details.skipCosmeticFiltering;
@@ -147,11 +139,6 @@ var filteringHandler = function(details) {
if ( details.netHide.length !== 0 ) {
netFilters(details);
}
- value = details.scriptTagRegex;
- if ( typeof value === 'string' && value.length !== 0 ) {
- vAPI.reScriptTagRegex = new RegExp(value);
- document.addEventListener('beforescriptexecute', onBeforeScriptExecuteHandler);
- }
// The port will never be used again at this point, disconnecting allows
// the browser to flush this script from memory.
}
diff --git a/src/js/cosmetic-filtering.js b/src/js/cosmetic-filtering.js
index 8a0afa8..1a0c873 100644
--- a/src/js/cosmetic-filtering.js
+++ b/src/js/cosmetic-filtering.js
@@ -237,7 +237,7 @@ var FilterParser = function() {
this.invalid = false;
this.cosmetic = true;
this.reParser = /^\s*([^#]*)(##|#@#)(.+)\s*$/;
- this.reScriptSelectorParser = /^script:contains\(\/.+?\/\)$/;
+ this.reScriptContains = /^script:contains\(.+?\)$/;
};
/******************************************************************************/
@@ -286,16 +286,20 @@ FilterParser.prototype.parse = function(s) {
// Script tag filters: pre-process them so that can be used with minimal
// overhead in the content script.
- if (
- this.suffix.charAt(0) === 's' &&
- this.reScriptSelectorParser.test(this.suffix)
- ) {
+ // Example: focus.de##script:contains(/uabInject/)
+ if ( this.suffix.charAt(0) === 's' && this.reScriptContains.test(this.suffix) ) {
// Currently supported only as non-generic selector.
if ( this.prefix.length === 0 ) {
this.invalid = true;
return this;
}
- this.suffix = 'script//:' + this.suffix.slice(17, -2).replace(/\\/g, '\\');
+ var suffix = this.suffix;
+ this.suffix = 'script//:';
+ if ( suffix.charAt(16) !== '/' || suffix.slice(-2) !== '/)' ) {
+ this.suffix += suffix.slice(16, -1).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
+ } else {
+ this.suffix += suffix.slice(17, -2).replace(/\\/g, '\\');
+ }
}
this.unhide = matches[2].charAt(1) === '@' ? 1 : 0;
@@ -1257,7 +1261,6 @@ FilterContainer.prototype.retrieveDomainSelectors = function(request) {
cosmeticHide: [],
cosmeticDonthide: [],
netHide: [],
- scriptTagRegex: this.retrieveScriptTagRegex(domain, hostname),
netCollapse: µb.userSettings.collapseBlocked
};