Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/filterComposer.js

Issue 6393086494113792: Issue 154 - Added devtools panel showing blocked and blockable items (Closed)
Left Patch Set: Fixed a typo, updated dependency, tidied up some code Created Feb. 2, 2016, 1:21 p.m.
Right Patch Set: Adapt for UI changes generating domain specific filters when necessary Created Feb. 3, 2016, 10:40 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/devtools.js ('k') | lib/whitelisting.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 let filters = []; 89 let filters = [];
90 let selectors = []; 90 let selectors = [];
91 91
92 let page = details.page; 92 let page = details.page;
93 let frame = details.frame; 93 let frame = details.frame;
94 94
95 if (!checkWhitelisted(page, frame)) 95 if (!checkWhitelisted(page, frame))
96 { 96 {
97 let typeMask = RegExpFilter.typeMap[details.type]; 97 let typeMask = RegExpFilter.typeMap[details.type];
98 let docDomain = extractHostFromFrame(frame); 98 let docDomain = extractHostFromFrame(frame);
99 let specificOnly = checkWhitelisted(page, frame, RegExpFilter.typeMap.GENERI CBLOCK);
99 100
100 // Add a blocking filter for each URL of the element that can be blocked 101 // Add a blocking filter for each URL of the element that can be blocked
101 for (let url of details.urls) 102 for (let url of details.urls)
102 { 103 {
103 let urlObj = new URL(url, details.baseURL); 104 let urlObj = new URL(url, details.baseURL);
104 url = stringifyURL(urlObj); 105 url = stringifyURL(urlObj);
105 106
106 let filter = defaultMatcher.whitelist.matchesAny( 107 let filter = defaultMatcher.whitelist.matchesAny(
107 url, typeMask, docDomain, 108 url, typeMask, docDomain,
108 isThirdParty(urlObj, docDomain), 109 isThirdParty(urlObj, docDomain),
109 getKey(page, frame) 110 getKey(page, frame), specificOnly
110 ); 111 );
111 112
112 if (!filter) 113 if (!filter)
113 { 114 {
114 let filterText = url.replace(/^[\w\-]+:\/+(?:www\.)?/, "||"); 115 let filterText = url.replace(/^[\w\-]+:\/+(?:www\.)?/, "||");
116
117 if (specificOnly)
118 filterText += "$domain=" + docDomain;
115 119
116 if (filters.indexOf(filterText) == -1) 120 if (filters.indexOf(filterText) == -1)
117 filters.push(filterText); 121 filters.push(filterText);
118 } 122 }
119 } 123 }
120 124
121 // If we couldn't generate any blocking filters, fallback to element hiding 125 // If we couldn't generate any blocking filters, fallback to element hiding
122 let selectors = []; 126 let selectors = [];
123 if (filters.length == 0 && !checkWhitelisted(page, frame, RegExpFilter.typeM ap.ELEMHIDE)) 127 if (filters.length == 0 && !checkWhitelisted(page, frame, RegExpFilter.typeM ap.ELEMHIDE))
124 { 128 {
(...skipping 16 matching lines...) Expand all
141 selectors.push(escapeCSS(details.tagName) + "[style=" + quoteCSS(details .style) + "]"); 145 selectors.push(escapeCSS(details.tagName) + "[style=" + quoteCSS(details .style) + "]");
142 146
143 // Add an element hiding filter for each generated CSS selector 147 // Add an element hiding filter for each generated CSS selector
144 for (let selector of selectors) 148 for (let selector of selectors)
145 filters.push(docDomain.replace(/^www\./, "") + "##" + selector); 149 filters.push(docDomain.replace(/^www\./, "") + "##" + selector);
146 } 150 }
147 } 151 }
148 152
149 return {filters: filters, selectors: selectors}; 153 return {filters: filters, selectors: selectors};
150 }; 154 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld