function init(){window.addEventListener("keydown",onKeyDown,!1),window.addEventListener("dragstart",onDragStart,!1),window.addEventListener("drag",onDrag,!1),window.addEventListener("dragend",onDragEnd,!1),$("#addButton").click(addFilters),$("#cancelButton").click(closeDialog.bind(null,!1)),$("#close").click(closeDialog.bind(null,!1)),chrome.extension.sendRequest({reqtype:"forward",request:{reqtype:"clickhide-init",width:Math.max(document.body.offsetWidth,document.body.scrollWidth),height:document.body.offsetHeight}},function(a){document.getElementById("filters").value=a.filters.join("\n")}),document.getElementById("filters").focus()}function onKeyDown(a){27==a.keyCode?(a.preventDefault(),closeDialog()):13!=a.keyCode||a.shiftKey||a.ctrlKey||(a.preventDefault(),addFilters())}function addFilters(){var a=document.getElementById("filters").value.split(/[\r\n]+/).map(function(a){return a.replace(/^\s+/,"").replace(/\s+$/,"")}).filter(function(a){return""!=a});chrome.extension.sendRequest({reqtype:"add-filters",filters:a}),closeDialog(!0)}function closeDialog(a){chrome.extension.sendRequest({reqtype:"forward",request:{reqtype:"clickhide-close",remove:"boolean"==typeof a?a:!1}})}function onDragStart(a){dragCoords=[a.screenX,a.screenY]}function onDrag(a){if(dragCoords&&(a.screenX||a.screenY)){var b=[a.screenX-dragCoords[0],a.screenY-dragCoords[1]];(b[0]||b[1])&&(chrome.extension.sendRequest({reqtype:"forward",request:{reqtype:"clickhide-move",x:b[0],y:b[1]}}),dragCoords=[a.screenX,a.screenY])}}function onDragEnd(a){onDrag(a),dragCoords=null}$(init);var dragCoords=null;