OLD | NEW |
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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 { | 246 { |
247 let tabId = page.id; | 247 let tabId = page.id; |
248 let panel = panels.get(tabId); | 248 let panel = panels.get(tabId); |
249 | 249 |
250 // Reloading the tab is the only way that allows bypassing all caches, in | 250 // Reloading the tab is the only way that allows bypassing all caches, in |
251 // order to see all requests in the devtools panel. Reloading must not be | 251 // order to see all requests in the devtools panel. Reloading must not be |
252 // performed before the tab changes to "loading", otherwise it will load the | 252 // performed before the tab changes to "loading", otherwise it will load the |
253 // previous URL. | 253 // previous URL. |
254 if (panel && panel.reload) | 254 if (panel && panel.reload) |
255 { | 255 { |
256 chrome.tabs.reload(tabId, {bypassCache: true}); | 256 browser.tabs.reload(tabId, {bypassCache: true}); |
257 | 257 |
258 panel.reload = false; | 258 panel.reload = false; |
259 panel.reloading = true; | 259 panel.reloading = true; |
260 } | 260 } |
261 } | 261 } |
262 | 262 |
263 function updateFilters(filters, added) | 263 function updateFilters(filters, added) |
264 { | 264 { |
265 for (let panel of panels.values()) | 265 for (let panel of panels.values()) |
266 { | 266 { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 { | 327 { |
328 updateFilters([filter], false); | 328 updateFilters([filter], false); |
329 } | 329 } |
330 | 330 |
331 function onSubscriptionAdded(subscription) | 331 function onSubscriptionAdded(subscription) |
332 { | 332 { |
333 if (subscription instanceof SpecialSubscription) | 333 if (subscription instanceof SpecialSubscription) |
334 updateFilters(subscription.filters, true); | 334 updateFilters(subscription.filters, true); |
335 } | 335 } |
336 | 336 |
337 chrome.runtime.onConnect.addListener(newPort => | 337 browser.runtime.onConnect.addListener(newPort => |
338 { | 338 { |
339 let match = newPort.name.match(/^devtools-(\d+)$/); | 339 let match = newPort.name.match(/^devtools-(\d+)$/); |
340 if (!match) | 340 if (!match) |
341 return; | 341 return; |
342 | 342 |
343 let inspectedTabId = parseInt(match[1], 10); | 343 let inspectedTabId = parseInt(match[1], 10); |
344 let localOnBeforeRequest = onBeforeRequest.bind(); | 344 let localOnBeforeRequest = onBeforeRequest.bind(); |
345 | 345 |
346 chrome.webRequest.onBeforeRequest.addListener( | 346 browser.webRequest.onBeforeRequest.addListener( |
347 localOnBeforeRequest, | 347 localOnBeforeRequest, |
348 { | 348 { |
349 urls: ["http://*/*", "https://*/*"], | 349 urls: ["http://*/*", "https://*/*"], |
350 types: ["main_frame"], | 350 types: ["main_frame"], |
351 tabId: inspectedTabId | 351 tabId: inspectedTabId |
352 } | 352 } |
353 ); | 353 ); |
354 | 354 |
355 if (panels.size == 0) | 355 if (panels.size == 0) |
356 { | 356 { |
357 ext.pages.onLoading.addListener(onLoading); | 357 ext.pages.onLoading.addListener(onLoading); |
358 FilterNotifier.on("filter.added", onFilterAdded); | 358 FilterNotifier.on("filter.added", onFilterAdded); |
359 FilterNotifier.on("filter.removed", onFilterRemoved); | 359 FilterNotifier.on("filter.removed", onFilterRemoved); |
360 FilterNotifier.on("subscription.added", onSubscriptionAdded); | 360 FilterNotifier.on("subscription.added", onSubscriptionAdded); |
361 } | 361 } |
362 | 362 |
363 newPort.onDisconnect.addListener(() => | 363 newPort.onDisconnect.addListener(() => |
364 { | 364 { |
365 panels.delete(inspectedTabId); | 365 panels.delete(inspectedTabId); |
366 chrome.webRequest.onBeforeRequest.removeListener(localOnBeforeRequest); | 366 browser.webRequest.onBeforeRequest.removeListener(localOnBeforeRequest); |
367 | 367 |
368 if (panels.size == 0) | 368 if (panels.size == 0) |
369 { | 369 { |
370 ext.pages.onLoading.removeListener(onLoading); | 370 ext.pages.onLoading.removeListener(onLoading); |
371 FilterNotifier.off("filter.added", onFilterAdded); | 371 FilterNotifier.off("filter.added", onFilterAdded); |
372 FilterNotifier.off("filter.removed", onFilterRemoved); | 372 FilterNotifier.off("filter.removed", onFilterRemoved); |
373 FilterNotifier.off("subscription.added", onSubscriptionAdded); | 373 FilterNotifier.off("subscription.added", onSubscriptionAdded); |
374 } | 374 } |
375 }); | 375 }); |
376 | 376 |
377 panels.set(inspectedTabId, {port: newPort, records: []}); | 377 panels.set(inspectedTabId, {port: newPort, records: []}); |
378 }); | 378 }); |
379 | 379 |
380 port.on("devtools.traceElemHide", (message, sender) => | 380 port.on("devtools.traceElemHide", (message, sender) => |
381 { | 381 { |
382 logHiddenElements( | 382 logHiddenElements( |
383 sender.page, message.selectors, message.filters, | 383 sender.page, message.selectors, message.filters, |
384 extractHostFromFrame(sender.frame) | 384 extractHostFromFrame(sender.frame) |
385 ); | 385 ); |
386 }); | 386 }); |
OLD | NEW |