| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 // Click-to-hide stuff | 18 // Click-to-hide stuff |
| 19 var clickHide_activated = false; | 19 var clickHide_activated = false; |
| 20 var clickHide_filters = null; | 20 var clickHide_filters = null; |
| 21 var currentElement = null; | 21 var currentElement = null; |
| 22 var clickHideFilters = null; | 22 var clickHideFilters = null; |
| 23 var highlightedElementsSelector = null; | 23 var highlightedElementsSelector = null; |
| 24 var clickHideFiltersDialog = null; | 24 var clickHideFiltersDialog = null; |
| 25 var lastRightClickEvent = null; | 25 var lastRightClickEvent = null; |
| 26 | 26 |
| 27 var ctrlChar = /[\x00-\x1F\x7F]/; | |
| 28 | |
| 29 function escapeChar(chr) | 27 function escapeChar(chr) |
| 30 { | 28 { |
| 31 if (ctrlChar.test(chr) || /\d/.test(chr)) | 29 var code = chr.charCodeAt(0); |
| 32 return "\\" + chr.charCodeAt(0).toString(16) + " "; | 30 |
| 31 if (code <= 0x1F || code == 0x7F || /\d/.test(chr)) | |
| 32 return "\\" + code.toString(16) + " "; | |
| 33 | 33 |
| 34 return "\\" + chr; | 34 return "\\" + chr; |
| 35 } | 35 } |
| 36 | 36 |
| 37 function quote(value) | 37 function quote(value) |
| 38 { | 38 { |
| 39 return '"' + value.replace(new RegExp('["\\\\]|' + ctrlChar.source, "g"), esca peChar) + '"'; | 39 return '"' + value.replace(/["\\\x00-\x1F\x7F]/g, escapeChar) + '"'; |
|
Wladimir Palant
2014/11/06 21:26:06
Generating regular expressions dynamically for no
Sebastian Noack
2014/11/10 12:13:18
The idea was not to hard-code the char codes for c
| |
| 40 } | 40 } |
| 41 | 41 |
| 42 function escapeCSS(s) | 42 function escapeCSS(s) |
| 43 { | 43 { |
| 44 return s.replace(/^\d|^-(?![^\d\-])|[^\w\-\u0080-\uFFFF]/g, escapeChar); | 44 return s.replace(/^[\d\-]|[^\w\-\u0080-\uFFFF]/g, escapeChar); |
|
Wladimir Palant
2014/11/06 21:26:06
Thinking more about this, I'm definitely opposed t
Sebastian Noack
2014/11/10 12:13:18
It's probably not worth to argue here. But I still
| |
| 45 } | 45 } |
| 46 | 46 |
| 47 function supportsShadowRoot(element) | 47 function supportsShadowRoot(element) |
| 48 { | 48 { |
| 49 if (!("createShadowRoot" in element)) | 49 if (!("createShadowRoot" in element)) |
| 50 return false; | 50 return false; |
| 51 | 51 |
| 52 // There are some elements (e.g. <textarea>), which don't | 52 // There are some elements (e.g. <textarea>), which don't |
| 53 // support author created shadow roots and throw an exception. | 53 // support author created shadow roots and throw an exception. |
| 54 var clone = element.cloneNode(false); | 54 var clone = element.cloneNode(false); |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 670 break; | 670 break; |
| 671 default: | 671 default: |
| 672 sendResponse({}); | 672 sendResponse({}); |
| 673 break; | 673 break; |
| 674 } | 674 } |
| 675 }); | 675 }); |
| 676 | 676 |
| 677 if (window == window.top) | 677 if (window == window.top) |
| 678 ext.backgroundPage.sendMessage({type: "report-html-page"}); | 678 ext.backgroundPage.sendMessage({type: "report-html-page"}); |
| 679 } | 679 } |
| LEFT | RIGHT |