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

Side by Side Diff: include.postload.js

Issue 5186743326212096: Issue 1843 - Deactivate "Block element" dialog when extension is disabled/uninstalled/reloaded (Closed)
Patch Set: Created Jan. 23, 2015, 9:47 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 var element = elts[i]; 351 var element = elts[i];
352 if (isBlockable(element)) 352 if (isBlockable(element))
353 addElementOverlay(element); 353 addElementOverlay(element);
354 } 354 }
355 355
356 clickHide_activated = true; 356 clickHide_activated = true;
357 document.addEventListener("mouseover", clickHide_mouseOver, true); 357 document.addEventListener("mouseover", clickHide_mouseOver, true);
358 document.addEventListener("mouseout", clickHide_mouseOut, true); 358 document.addEventListener("mouseout", clickHide_mouseOut, true);
359 document.addEventListener("click", clickHide_mouseClick, true); 359 document.addEventListener("click", clickHide_mouseClick, true);
360 document.addEventListener("keydown", clickHide_keyDown, true); 360 document.addEventListener("keydown", clickHide_keyDown, true);
361
362 ext.onExtensionUnloaded.addListener(clickHide_deactivate);
361 } 363 }
362 364
363 // Called when user has clicked on something and we are waiting for confirmation 365 // Called when user has clicked on something and we are waiting for confirmation
364 // on whether the user actually wants these filters 366 // on whether the user actually wants these filters
365 function clickHide_rulesPending() { 367 function clickHide_rulesPending() {
366 clickHide_activated = false; 368 clickHide_activated = false;
367 document.removeEventListener("mouseover", clickHide_mouseOver, true); 369 document.removeEventListener("mouseover", clickHide_mouseOver, true);
368 document.removeEventListener("mouseout", clickHide_mouseOut, true); 370 document.removeEventListener("mouseout", clickHide_mouseOut, true);
369 document.removeEventListener("click", clickHide_mouseClick, true); 371 document.removeEventListener("click", clickHide_mouseClick, true);
370 document.removeEventListener("keydown", clickHide_keyDown, true); 372 document.removeEventListener("keydown", clickHide_keyDown, true);
(...skipping 10 matching lines...) Expand all
381 383
382 clickHide_activated = false; 384 clickHide_activated = false;
383 clickHide_filters = null; 385 clickHide_filters = null;
384 if(!document) 386 if(!document)
385 return; // This can happen inside a nuked iframe...I think 387 return; // This can happen inside a nuked iframe...I think
386 document.removeEventListener("mouseover", clickHide_mouseOver, true); 388 document.removeEventListener("mouseover", clickHide_mouseOver, true);
387 document.removeEventListener("mouseout", clickHide_mouseOut, true); 389 document.removeEventListener("mouseout", clickHide_mouseOut, true);
388 document.removeEventListener("click", clickHide_mouseClick, true); 390 document.removeEventListener("click", clickHide_mouseClick, true);
389 document.removeEventListener("keydown", clickHide_keyDown, true); 391 document.removeEventListener("keydown", clickHide_keyDown, true);
390 392
391 if (!keepOverlays) 393 if (keepOverlays !== true)
392 { 394 {
393 lastRightClickEvent = null; 395 lastRightClickEvent = null;
394 396
395 if (currentElement) { 397 if (currentElement) {
396 currentElement.removeEventListener("contextmenu", clickHide_elementClickH andler, true); 398 currentElement.removeEventListener("contextmenu", clickHide_elementClickH andler, true);
397 unhighlightElements(); 399 unhighlightElements();
398 unhighlightElement(currentElement); 400 unhighlightElement(currentElement);
399 currentElement = null; 401 currentElement = null;
400 } 402 }
401 unhighlightElements(); 403 unhighlightElements();
402 404
403 var overlays = document.getElementsByClassName("__adblockplus__overlay"); 405 var overlays = document.getElementsByClassName("__adblockplus__overlay");
404 while (overlays.length > 0) 406 while (overlays.length > 0)
405 overlays[0].parentNode.removeChild(overlays[0]); 407 overlays[0].parentNode.removeChild(overlays[0]);
408
409 ext.onExtensionUnloaded.removeListener(clickHide_deactivate);
406 } 410 }
407 } 411 }
408 412
409 function clickHide_elementClickHandler(ev) { 413 function clickHide_elementClickHandler(ev) {
410 ev.preventDefault(); 414 ev.preventDefault();
411 ev.stopPropagation(); 415 ev.stopPropagation();
412 clickHide_mouseClick(ev); 416 clickHide_mouseClick(ev);
413 } 417 }
414 418
415 // Hovering over an element so highlight it 419 // Hovering over an element so highlight it
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 lastRightClickEventValid = false; 733 lastRightClickEventValid = false;
730 else 734 else
731 lastRightClickEvent = null; 735 lastRightClickEvent = null;
732 break; 736 break;
733 } 737 }
734 }); 738 });
735 739
736 if (window == window.top) 740 if (window == window.top)
737 ext.backgroundPage.sendMessage({type: "report-html-page"}); 741 ext.backgroundPage.sendMessage({type: "report-html-page"});
738 } 742 }
OLDNEW
« chrome/ext/background.js ('K') | « chrome/ext/content.js ('k') | safari/ext/content.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld