| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 | 159 |
| 160 for (var i = 0; i < selectors.length; i++) | 160 for (var i = 0; i < selectors.length; i++) |
| 161 { | 161 { |
| 162 var selector = selectors[i]; | 162 var selector = selectors[i]; |
| 163 var start = 0; | 163 var start = 0; |
| 164 var sep = ""; | 164 var sep = ""; |
| 165 | 165 |
| 166 for (var j = 0; j < selector.length; j++) | 166 for (var j = 0; j < selector.length; j++) |
| 167 { | 167 { |
| 168 var chr = selector[j]; | 168 var chr = selector[j]; |
| 169 switch (chr) | 169 if (chr == "\\") |
| 170 { | 170 j++; |
| 171 case "\\": | 171 else if (chr == sep) |
| 172 j++; | 172 sep = ""; |
| 173 break; | 173 else if (chr == '"' || chr == "'") |
| 174 case sep: | 174 sep = chr; |
| 175 sep = ""; | 175 else if (chr == "," && sep == "") |
| 176 break; | 176 { |
| 177 case '"': | 177 result.push(prefix + selector.substring(start, j)); |
| 178 case "'": | 178 start = j + 1; |
| 179 sep = chr; | 179 } |
| 180 break; | 180 } |
|
Wladimir Palant
2015/01/22 08:15:52
Note that technically there might be more separato
| |
| 181 case ",": | 181 |
| 182 if (sep == "") | 182 result.push(prefix + selector.substring(start)); |
| 183 { | |
| 184 result.push(prefix + selector.substring(start, j)); | |
| 185 start = j + 1; | |
| 186 } | |
|
Wladimir Palant
2015/01/22 08:15:52
Nit: please add a break statement here, for consis
Sebastian Noack
2015/01/22 09:40:59
Ah, let's go with if/else then. It's more compact,
| |
| 187 } | |
| 188 } | |
| 189 | |
| 190 result.push(prefix + selector.substring(start, j)); | |
|
Wladimir Palant
2015/01/22 08:15:52
The second parameter is unnecessary here, can be s
Sebastian Noack
2015/01/22 09:40:59
Oh, you are right.
| |
| 191 } | 183 } |
| 192 | 184 |
| 193 return result; | 185 return result; |
| 194 } | 186 } |
| 195 | 187 |
| 196 function init(document) | 188 function init(document) |
| 197 { | 189 { |
| 198 // Use Shadow DOM if available to don't mess with web pages that rely on | 190 // Use Shadow DOM if available to don't mess with web pages that rely on |
| 199 // the order of their own <style> tags (#309). | 191 // the order of their own <style> tags (#309). |
| 200 // | 192 // |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 }, true); | 273 }, true); |
| 282 | 274 |
| 283 ext.backgroundPage.sendMessage({type: "get-selectors"}, setElemhideCSSRules); | 275 ext.backgroundPage.sendMessage({type: "get-selectors"}, setElemhideCSSRules); |
| 284 } | 276 } |
| 285 | 277 |
| 286 if (document instanceof HTMLDocument) | 278 if (document instanceof HTMLDocument) |
| 287 { | 279 { |
| 288 checkSitekey(); | 280 checkSitekey(); |
| 289 init(document); | 281 init(document); |
| 290 } | 282 } |
| LEFT | RIGHT |