| 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-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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 type: "composer.openDialog" | 388 type: "composer.openDialog" |
| 389 }, | 389 }, |
| 390 popupId => | 390 popupId => |
| 391 { | 391 { |
| 392 ext.backgroundPage.sendMessage( | 392 ext.backgroundPage.sendMessage( |
| 393 { | 393 { |
| 394 type: "forward", | 394 type: "forward", |
| 395 targetPageId: popupId, | 395 targetPageId: popupId, |
| 396 payload: | 396 payload: |
| 397 { | 397 { |
| 398 type: "blockelement-popup-init", | 398 type: "composer.dialog.init", |
| 399 filters: filters | 399 filters: filters |
| 400 } | 400 } |
| 401 }); | 401 }); |
| 402 | 402 |
| 403 // Only the top frame keeps a record of the popup window's ID, | 403 // Only the top frame keeps a record of the popup window's ID, |
| 404 // so if this isn't the top frame we need to pass the ID on. | 404 // so if this isn't the top frame we need to pass the ID on. |
| 405 if (window == window.top) | 405 if (window == window.top) |
| 406 { | 406 { |
| 407 blockelementPopupId = popupId; | 407 blockelementPopupId = popupId; |
| 408 } | 408 } |
| 409 else | 409 else |
| 410 { | 410 { |
| 411 ext.backgroundPage.sendMessage( | 411 ext.backgroundPage.sendMessage( |
| 412 { | 412 { |
| 413 type: "forward", | 413 type: "forward", |
| 414 payload: | 414 payload: |
| 415 { | 415 { |
| 416 type: "blockelement-popup-opened", | 416 type: "composer.content.dialogOpened", |
| 417 popupId: popupId | 417 popupId: popupId |
| 418 } | 418 } |
| 419 }); | 419 }); |
| 420 } | 420 } |
| 421 }); | 421 }); |
| 422 | 422 |
| 423 if (selectors.length > 0) | 423 if (selectors.length > 0) |
| 424 highlightElements(selectors.join(",")); | 424 highlightElements(selectors.join(",")); |
| 425 | 425 |
| 426 highlightElement(currentElement, "#fd1708", "#f6a1b5"); | 426 highlightElement(currentElement, "#fd1708", "#f6a1b5"); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 455 stopPickingElement(); | 455 stopPickingElement(); |
| 456 | 456 |
| 457 if (blockelementPopupId != null) | 457 if (blockelementPopupId != null) |
| 458 { | 458 { |
| 459 ext.backgroundPage.sendMessage( | 459 ext.backgroundPage.sendMessage( |
| 460 { | 460 { |
| 461 type: "forward", | 461 type: "forward", |
| 462 targetPageId: blockelementPopupId, | 462 targetPageId: blockelementPopupId, |
| 463 payload: | 463 payload: |
| 464 { | 464 { |
| 465 type: "blockelement-close-popup" | 465 type: "composer.dialog.close" |
| 466 } | 466 } |
| 467 }); | 467 }); |
| 468 | 468 |
| 469 blockelementPopupId = null; | 469 blockelementPopupId = null; |
| 470 } | 470 } |
| 471 | 471 |
| 472 lastRightClickEvent = null; | 472 lastRightClickEvent = null; |
| 473 | 473 |
| 474 if (currentElement) | 474 if (currentElement) |
| 475 { | 475 { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 501 document.addEventListener("contextmenu", event => | 501 document.addEventListener("contextmenu", event => |
| 502 { | 502 { |
| 503 lastRightClickEvent = event; | 503 lastRightClickEvent = event; |
| 504 lastRightClickEventIsMostRecent = true; | 504 lastRightClickEventIsMostRecent = true; |
| 505 | 505 |
| 506 ext.backgroundPage.sendMessage( | 506 ext.backgroundPage.sendMessage( |
| 507 { | 507 { |
| 508 type: "forward", | 508 type: "forward", |
| 509 payload: | 509 payload: |
| 510 { | 510 { |
| 511 type: "blockelement-clear-previous-right-click-event" | 511 type: "composer.content.clearPreviousRightClickEvent" |
| 512 } | 512 } |
| 513 }); | 513 }); |
| 514 }, true); | 514 }, true); |
| 515 | 515 |
| 516 ext.onMessage.addListener((msg, sender, sendResponse) => | 516 ext.onMessage.addListener((msg, sender, sendResponse) => |
| 517 { | 517 { |
| 518 switch (msg.type) | 518 switch (msg.type) |
| 519 { | 519 { |
| 520 case "blockelement-get-state": | 520 case "composer.content.getState": |
| 521 if (window == window.top) | 521 if (window == window.top) |
| 522 sendResponse({ | 522 sendResponse({ |
| 523 active: currentlyPickingElement || blockelementPopupId != null | 523 active: currentlyPickingElement || blockelementPopupId != null |
| 524 }); | 524 }); |
| 525 break; | 525 break; |
| 526 case "blockelement-start-picking-element": | 526 case "composer.content.startPickingElement": |
| 527 if (window == window.top) | 527 if (window == window.top) |
| 528 startPickingElement(); | 528 startPickingElement(); |
| 529 break; | 529 break; |
| 530 case "blockelement-context-menu-clicked": | 530 case "composer.content.contextMenuClicked": |
| 531 let event = lastRightClickEvent; | 531 let event = lastRightClickEvent; |
| 532 deactivateBlockElement(); | 532 deactivateBlockElement(); |
| 533 if (event) | 533 if (event) |
| 534 { | 534 { |
| 535 getBlockableElementOrAncestor(event.target, element => | 535 getBlockableElementOrAncestor(event.target, element => |
| 536 { | 536 { |
| 537 if (element) | 537 if (element) |
| 538 { | 538 { |
| 539 currentElement = element; | 539 currentElement = element; |
| 540 elementPicked(event); | 540 elementPicked(event); |
| 541 } | 541 } |
| 542 }); | 542 }); |
| 543 } | 543 } |
| 544 break; | 544 break; |
| 545 case "blockelement-finished": | 545 case "composer.content.finished": |
| 546 if (currentElement && msg.remove) | 546 if (currentElement && msg.remove) |
| 547 { | 547 { |
| 548 // Hide the selected element itself if an added blocking | 548 // Hide the selected element itself if an added blocking |
| 549 // filter is causing it to collapse. Note that this | 549 // filter is causing it to collapse. Note that this |
| 550 // behavior is incomplete, but the best we can do here, | 550 // behavior is incomplete, but the best we can do here, |
| 551 // e.g. if an added blocking filter matches other elements, | 551 // e.g. if an added blocking filter matches other elements, |
| 552 // the effect won't be visible until the page is is reloaded. | 552 // the effect won't be visible until the page is is reloaded. |
| 553 checkCollapse(currentElement.prisoner || currentElement); | 553 checkCollapse(currentElement.prisoner || currentElement); |
| 554 | 554 |
| 555 // Apply added element hiding filters. | 555 // Apply added element hiding filters. |
| 556 updateStylesheet(); | 556 updateStylesheet(); |
| 557 } | 557 } |
| 558 deactivateBlockElement(); | 558 deactivateBlockElement(); |
| 559 break; | 559 break; |
| 560 case "blockelement-clear-previous-right-click-event": | 560 case "composer.content.clearPreviousRightClickEvent": |
| 561 if (!lastRightClickEventIsMostRecent) | 561 if (!lastRightClickEventIsMostRecent) |
| 562 lastRightClickEvent = null; | 562 lastRightClickEvent = null; |
| 563 lastRightClickEventIsMostRecent = false; | 563 lastRightClickEventIsMostRecent = false; |
| 564 break; | 564 break; |
| 565 case "blockelement-popup-opened": | 565 case "composer.content.dialogOpened": |
| 566 if (window == window.top) | 566 if (window == window.top) |
| 567 blockelementPopupId = msg.popupId; | 567 blockelementPopupId = msg.popupId; |
| 568 break; | 568 break; |
| 569 case "blockelement-popup-closed": | 569 case "composer.content.dialogClosed": |
| 570 // The onRemoved hook for the popup can create a race condition, so we | 570 // The onRemoved hook for the popup can create a race condition, so we |
| 571 // to be careful here. (This is not perfect, but best we can do.) | 571 // to be careful here. (This is not perfect, but best we can do.) |
| 572 if (window == window.top && blockelementPopupId == msg.popupId) | 572 if (window == window.top && blockelementPopupId == msg.popupId) |
| 573 { | 573 { |
| 574 ext.backgroundPage.sendMessage( | 574 ext.backgroundPage.sendMessage( |
| 575 { | 575 { |
| 576 type: "forward", | 576 type: "forward", |
| 577 payload: | 577 payload: |
| 578 { | 578 { |
| 579 type: "blockelement-finished" | 579 type: "composer.content.finished" |
| 580 } | 580 } |
| 581 }); | 581 }); |
| 582 } | 582 } |
| 583 break; | 583 break; |
| 584 } | 584 } |
| 585 }); | 585 }); |
| 586 | 586 |
| 587 if (window == window.top) | 587 if (window == window.top) |
| 588 ext.backgroundPage.sendMessage({type: "composer.ready"}); | 588 ext.backgroundPage.sendMessage({type: "composer.ready"}); |
| 589 } | 589 } |
| OLD | NEW |