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

Side by Side Diff: include.postload.js

Issue 4840054052618240: Issue 1428 - Disable "Block Element" on non-HTML pages (Closed)
Patch Set: Removed outdated comment Created Sept. 26, 2014, 10:21 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
« no previous file with comments | « background.js ('k') | popup.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 if(!components) 472 if(!components)
473 return url; 473 return url;
474 var newPath = removeDotSegments(components[2]); 474 var newPath = removeDotSegments(components[2]);
475 if(newPath.length == 0) 475 if(newPath.length == 0)
476 return components[1]; 476 return components[1];
477 if(newPath[0] != '/') 477 if(newPath[0] != '/')
478 newPath = '/' + newPath; 478 newPath = '/' + newPath;
479 return components[1] + newPath; 479 return components[1] + newPath;
480 } 480 }
481 481
482 // Content scripts are apparently invoked on non-HTML documents, so we have to 482 if (document instanceof HTMLDocument)
483 // check for that before doing stuff. |document instanceof HTMLDocument| check
484 // will fail on some sites like planet.mozilla.org because WebKit creates
485 // Document instances for XHTML documents, have to test the root element.
486 if (document.documentElement instanceof HTMLElement)
487 { 483 {
488 // Use a contextmenu handler to save the last element the user right-clicked o n. 484 // Use a contextmenu handler to save the last element the user right-clicked o n.
489 // To make things easier, we actually save the DOM event. 485 // To make things easier, we actually save the DOM event.
490 // We have to do this because the contextMenu API only provides a URL, not the actual 486 // We have to do this because the contextMenu API only provides a URL, not the actual
491 // DOM element. 487 // DOM element.
492 document.addEventListener('contextmenu', function(e) { 488 document.addEventListener('contextmenu', function(e) {
493 lastRightClickEvent = e; 489 lastRightClickEvent = e;
494 }, false); 490 }, false);
495 491
496 document.addEventListener("click", function(event) 492 document.addEventListener("click", function(event)
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 currentElement.parentNode.removeChild(currentElement); 634 currentElement.parentNode.removeChild(currentElement);
639 635
640 clickHide_deactivate(); 636 clickHide_deactivate();
641 } 637 }
642 break; 638 break;
643 default: 639 default:
644 sendResponse({}); 640 sendResponse({});
645 break; 641 break;
646 } 642 }
647 }); 643 });
644
645 if (window == window.top)
646 ext.backgroundPage.sendMessage({type: "report-html-page"});
648 } 647 }
OLDNEW
« no previous file with comments | « background.js ('k') | popup.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld