| 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-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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 port.onMessage.addListener((message) => | 565 port.onMessage.addListener((message) => |
| 566 { | 566 { |
| 567 switch (message.type) | 567 switch (message.type) |
| 568 { | 568 { |
| 569 case "app.respond": | 569 case "app.respond": |
| 570 switch (message.action) | 570 switch (message.action) |
| 571 { | 571 { |
| 572 case "devLog": | 572 case "devLog": |
| 573 const [request, filter, subscriptions] = message.args; | 573 const [request, filter, subscriptions] = message.args; |
| 574 | 574 |
| 575 let existingRequest = reportData.querySelector(`[location="${request.u
rl}"]`); | 575 let existingRequest = reportData. |
| 576 // TODO: refactor the implementation | 576 querySelector(`[location="${request.url}"]`); |
| 577 if (existingRequest) | 577 if (existingRequest) |
| 578 { | 578 { |
| 579 let countNum = Number(existingRequest.getAttribute("count")); | 579 let countNum = Number(existingRequest.getAttribute("count")); |
| 580 existingRequest.setAttribute("count", countNum + 1); | 580 existingRequest.setAttribute("count", countNum + 1); |
| 581 } | 581 } |
| 582 else | 582 else |
| 583 { | 583 { |
| 584 let requestElem = reportData.createElement("request"); | 584 let requestElem = reportData.createElement("request"); |
| 585 requestElem.setAttribute("location", request.url); | 585 requestElem.setAttribute("location", request.url); |
| 586 requestElem.setAttribute("type", request.type); | 586 requestElem.setAttribute("type", request.type); |
| 587 requestElem.setAttribute("docDomain", request.docDomain); | 587 requestElem.setAttribute("docDomain", request.docDomain); |
| 588 requestElem.setAttribute("thirdParty", request.thirdParty); | 588 requestElem.setAttribute("thirdParty", request.thirdParty); |
| 589 requestElem.setAttribute("count", 1); | 589 requestElem.setAttribute("count", 1); |
| 590 reportData.documentElement.appendChild(requestElem); | 590 reportData.documentElement.appendChild(requestElem); |
| 591 } | 591 } |
| 592 if (filter) | 592 if (filter) |
| 593 { | 593 { |
| 594 let existingFilter = reportData.querySelector(`[text="${filter.text}
"]`); | 594 let existingFilter = reportData. |
| 595 querySelector(`[text="${filter.text}"]`); |
| 595 if (existingFilter) | 596 if (existingFilter) |
| 596 { | 597 { |
| 597 let countNum = Number(existingFilter.getAttribute("hitcount")); | 598 let countNum = Number(existingFilter.getAttribute("hitcount")); |
| 598 existingFilter.setAttribute("hitcount", countNum + 1); | 599 existingFilter.setAttribute("hitcount", countNum + 1); |
| 599 } | 600 } |
| 600 else | 601 else |
| 601 { | 602 { |
| 602 let filterElem = reportData.createElement("filter"); | 603 let filterElem = reportData.createElement("filter"); |
| 603 filterElem.setAttribute("text", filter.text); | 604 filterElem.setAttribute("text", filter.text); |
| 604 filterElem.setAttribute("subscriptions", subscriptions.join(",")); | 605 filterElem.setAttribute("subscriptions", subscriptions.join(",")); |
| 605 filterElem.setAttribute("hitcount", 1); | 606 filterElem.setAttribute("hitcount", 1); |
| 606 reportData.documentElement.appendChild(filterElem); | 607 reportData.documentElement.appendChild(filterElem); |
| 607 } | 608 } |
| 608 } | 609 } |
| 609 break; | 610 break; |
| 610 } | 611 } |
| 611 break; | 612 break; |
| 612 } | 613 } |
| 613 }); | 614 }); |
| 614 | 615 |
| 615 port.postMessage({ | 616 port.postMessage({ |
| 616 type: "app.listen", | 617 type: "app.listen", |
| 617 filter: ["devLog"] | 618 filter: ["devLog"] |
| 618 }); | 619 }); |
| LEFT | RIGHT |