diff --git a/dist/build.min.js b/dist/build.min.js index e544d4a1a..6fc69f8af 100644 --- a/dist/build.min.js +++ b/dist/build.min.js @@ -1,3 +1,3 @@ -/*! 04-10-2016 */ +/*! 04-11-2016 */ function isEmpty(a){return a&&0!=a.length&&(1!=a.length||a[0].url&&"about:blank"!=a[0].url)?!1:!0}function bindWebviewEvent(a,b){webviewEvents.push({event:a,fn:b})}function bindWebviewIPC(a,b){webviewIPC.push({name:a,fn:b})}function pagePermissionRequestHandler(a,b,c){c("notifications"===b||"fullscreen"===b?!0:!1)}function onPageLoad(a){var b=this.getAttribute("data-tab"),c=this.getAttribute("src");0===c.indexOf("https://")||0==c.indexOf("about:")||0==c.indexOf("chrome:")||0==c.indexOf("file://")?tabs.update(b,{secure:!0,url:c}):tabs.update(b,{secure:!1,url:c});var d=-1!=c.indexOf(__dirname)&&-1==c.indexOf(readerView.readerURL);0!=tabs.get(b)["private"]||d||bookmarks.updateHistory(b),rerenderTabElement(b),this.send("loadfinish")}function getWebviewDom(a){var b=document.createElement("webview");if(b.setAttribute("preload","dist/webview.min.js"),a.url&&b.setAttribute("src",urlParser.parse(a.url)),b.setAttribute("data-tab",a.tabId),1==tabs.get(a.tabId)["private"]){var c=a.tabId.toString();b.setAttribute("partition",c),remote.session.fromPartition(c).setPermissionRequestHandler(pagePermissionRequestHandler),registerFiltering(c)}return webviewEvents.forEach(function(a){b.addEventListener(a.event,a.fn)}),b.addEventListener("page-favicon-updated",function(a){var b=this.getAttribute("data-tab");updateTabColor(a.favicons,b)}),b.addEventListener("page-title-set",function(a){var b=this.getAttribute("data-tab");tabs.update(b,{title:a.title}),rerenderTabElement(b)}),b.addEventListener("did-finish-load",onPageLoad),b.addEventListener("did-navigate-in-page",onPageLoad),b.addEventListener("new-window",function(a){var b=this.getAttribute("data-tab"),c=tabs.getIndex(tabs.getSelected()),d=tabs.add({url:a.url,"private":tabs.get(b)["private"]},c+1);addTab(d,{enterEditMode:!1,openInBackground:"background-tab"==a.disposition})}),b.addEventListener("close",function(a){var b=this.getAttribute("data-tab"),c=tabs.getSelected(),d=tabs.getIndex(b),e=tabs.getAtIndex(d-1)||tabs.getAtIndex(d+1);destroyTab(b),b==c&&(e?switchToTab(e.id):addTab())}),b.addEventListener("ipc-message",function(a){var b=this,c=this.getAttribute("data-tab");webviewIPC.forEach(function(d){d.name==a.channel&&d.fn(b,c,a.args)}),"bookmarksData"==a.channel?bookmarks.onDataRecieved(a.args[0]):"phishingDetected"==a.channel&&navigate(this.getAttribute("data-tab"),phishingWarningPage)}),b.addEventListener("contextmenu",webviewMenu.show),b.addEventListener("crashed",function(a){var b=this.getAttribute("data-tab");destroyWebview(b),tabs.update(b,{url:crashedWebviewPage}),addWebview(b),switchToWebview(b)}),b.addEventListener("did-fail-load",function(a){-3!=a.errorCode&&a.validatedURL==a.target.getURL()&&navigate(this.getAttribute("data-tab"),errorPage+"?ec="+encodeURIComponent(a.errorCode)+"&url="+a.target.getURL())}),b.addEventListener("enter-html-full-screen",function(a){this.classList.add("fullscreen")}),b.addEventListener("leave-html-full-screen",function(a){this.classList.remove("fullscreen")}),b}function addWebview(a){var b=tabs.get(a),c=getWebviewDom({tabId:a,url:b.url});c.classList.add("hidden"),webviewBase.appendChild(c)}function switchToWebview(a){for(var b=document.getElementsByTagName("webview"),c=0;cg?(clearTimeout(e),e=setTimeout(function(){d=g,a.apply(f,h)},b)):(d=g,a.apply(f,h))}}function debounce(a,b){var c=null;return function(){var d=this,e=arguments;clearTimeout(c),c=setTimeout(function(){a.apply(d,e)},b)}}function empty(a){for(var b;b=a.firstElementChild;)a.removeChild(b)}function removeTags(a){return a.replace(/<.*?>/g,"")}function openURLInBackground(a){var b=tabs.add({url:a,"private":tabs.get(tabs.getSelected())["private"]},tabs.getIndex(tabs.getSelected())+1);addTab(b,{enterEditMode:!1,openInBackground:!0,leaveEditMode:!1});var c=searchbar.querySelector(".searchbar-item:focus");c&&c.blur()}function openURLFromsearchbar(a,b){return a.metaKey?(openURLInBackground(b),!0):(navigate(tabs.getSelected(),b),!tabs.get(tabs.getSelected())["private"],!1)}function getRealTitle(a){if(urlParser.isURL(a))return a;for(var b=["|",":"," - "," — "],c=0;c=2&&(e[0]=e[0].trim(),e[1]=e[1].trim(),e[1].length<5||e[1].length/e[0].length<=.5))return e[0]}return a}function createSearchbarItem(a){var b=document.createElement("div");if(b.classList.add("searchbar-item"),b.setAttribute("tabindex","-1"),a.classList)for(var c=0;c50&&b.deltaY<3&&Date.now()-lastItemDeletion>700&&(lastItemDeletion=Date.now(),c.style.opacity="0",c.style.transform="translateX(-100%)",setTimeout(function(){a["delete"](c),c.parentNode.removeChild(c),lastItemDeletion=Date.now()},200))}),b}function showSearchbar(a){document.body.classList.add("searchbar-shown"),searchbar.hidden=!1,currentSearchbarInput=a}function getValue(a){var b=a.value;return b.replace(b.substring(a.selectionStart,a.selectionEnd),"")}function hidesearchbar(){currentSearchbarInput=null,document.body.classList.remove("searchbar-shown"),searchbar.hidden=!0,clearSearchbar()}function focussearchbarItem(a){a=a||{};var b=a.focusPrevious,c=[].slice.call(searchbar.querySelectorAll(".searchbar-item:not(.unfocusable)")),d=searchbar.querySelector(".searchbar-item:focus, .searchbar-item.fakefocus"),e=c.indexOf(d),f=c[b?e-1:e+1],g=searchbar.querySelector(".fakefocus");if(g&&g.classList.remove("fakefocus"),d&&f)f.focus();else{if(d)return void getTabInput(tabs.getSelected()).focus();c[0].focus()}var h=f||c[0];h.classList.contains("iadata-onfocus")&&setTimeout(function(){if(document.activeElement==h){var a=h.querySelector(".title").textContent;showSearchbarInstantAnswers(a,currentSearchbarInput,null,getSearchbarContainer("instantAnswers"))}},300)}function clearSearchbar(){for(var a=0;a(.+?)<.*/g,"$1"),c=a.Text.replace(b,""),a=createSearchbarItem({title:b,descriptionBlock:c,url:a.FirstURL});d.appendChild(a)}),searchbarResultCount+=Math.min(b.RelatedTopics.length,3));if(c&&(b.Answer?setTopAnswer("instantAnswers",c):d.appendChild(c)),4>searchbarResultCount&&b.Results&&b.Results[0]&&b.Results[0].FirstURL){var f=b.Results[0].FirstURL,e={icon:"fa-globe",title:urlParser.removeProtocol(f).replace(trailingSlashRegex,""),secondaryText:"Suggested site",url:f,classList:["ddg-answer"]},c=createSearchbarItem(e);d.appendChild(c)}var g=["location","country","u.s. state","protected area"];if(-1!=g.indexOf(b.Entity)){var c=createSearchbarItem({icon:"fa-search",title:b.Heading,secondaryText:"Search on OpenStreetMap",classList:["ddg-answer"],url:"https://www.openstreetmap.org/search?query="+encodeURIComponent(b.Heading)});d.insertBefore(c,d.firstChild)}})["catch"](function(a){console.error(a)})}function getBookmarkItem(a){var b=createSearchbarItem({icon:"fa-star",title:getRealTitle(a.title),secondaryText:urlParser.prettyURL(a.url),url:a.url});if(a.extraData&&a.extraData.metadata){var c=b.querySelector(".secondary-text");for(var d in a.extraData.metadata){var e=document.createElement("span");e.className="md-info",e.textContent=a.extraData.metadata[d],c.insertBefore(e,c.firstChild)}}return b}function showBookmarkResults(a,b,c,d){bookmarks.searchBookmarks(a,function(b){console.log(d),empty(d);var c=1;b.splice(0,2).forEach(function(b){(b.score>Math.max(4e-4,.0016-12e-5*Math.pow(1.3,a.length))||a.length>25)&&(1==c||a.length>6)&&(d.appendChild(getBookmarkItem(b)),c++)})})}function showAllBookmarks(){bookmarks.searchBookmarks("",function(a){a.sort(function(a,b){return a.urlb.url?1:0});var b=getSearchbarContainer("bookmarks");a.forEach(function(a){b.appendChild(getBookmarkItem(a))})})}function incrementBangCount(a){if(bangUseCounts[a]?bangUseCounts[a]++:bangUseCounts[a]=1,bangUseCounts[a]>1e3)for(var a in bangUseCounts)bangUseCounts[a]=Math.floor(.9*bangUseCounts[a]),bangUseCounts[a]<2&&delete bangUseCounts[a]}function showSearchSuggestions(a,b,c,d){return searchbarResultCount>3?void empty(d):void fetch("https://ac.duckduckgo.com/ac/?t=min&q="+encodeURIComponent(a),{cache:"force-cache"}).then(function(a){return a.json()}).then(function(a){empty(d),a&&a[0]&&a[0].snippet?(a.sort(function(a,b){var c=a.score||1,d=b.score||1;return bangUseCounts[a.phrase]&&(c*=bangUseCounts[a.phrase]),bangUseCounts[b.phrase]&&(d*=bangUseCounts[b.phrase]),d-c}),a.slice(0,5).forEach(function(a){cachedBangSnippets[a.phrase]=a.snippet;var c={image:a.image,imageIsInline:!0,title:a.snippet,secondaryText:a.phrase},e=createSearchbarItem(c);e.addEventListener("click",function(){setTimeout(function(){incrementBangCount(a.phrase),saveBangUseCounts(),b.value=a.phrase+" ",b.focus()},66)}),d.appendChild(e)})):a&&a.slice(0,3).forEach(function(a){var b={title:a.phrase};if(bangRegex.test(a.phrase)){b.title=a.phrase.replace(bangRegex,"");var c=a.phrase.match(bangRegex)[0];incrementBangCount(c),saveBangUseCounts(),b.secondaryText="Search on "+cachedBangSnippets[c]}urlParser.isURL(a.phrase)||urlParser.isURLMissingProtocol(a.phrase)?b.icon="fa-globe":b.icon="fa-search";var e=createSearchbarItem(b);e.addEventListener("click",function(b){openURLFromsearchbar(b,a.phrase)}),d.appendChild(e)}),searchbarResultCount+=a.length})}function showHistorySuggestions(a,b,c,d){var e=tabs.get(tabs.getSelected()).url;if(!e||"about:blank"==e){var f=tabs.getAtIndex(tabs.getIndex(tabs.getSelected())-1);f&&(e=f.url)}bookmarks.getHistorySuggestions(e,function(a){empty(d);var b=tabs.get().map(function(a){return a.url});a=a.filter(function(a){return-1==b.indexOf(a.url)}),a.slice(0,4).forEach(function(a){var b=createSearchbarItem({title:urlParser.prettyURL(a.url),secondaryText:getRealTitle(a.title),url:a.url,"delete":function(){bookmarks.deleteHistory(a.url)}});d.appendChild(b)})})}function getColor(a,b){colorExtractorImage.onload=function(a){var c=document.createElement("canvas"),d=c.getContext("2d"),e=colorExtractorImage.width,f=colorExtractorImage.height;c.width=e,c.height=f;var g=Math.max(1,Math.round(32e-5*e*f));d.drawImage(colorExtractorImage,0,0,e,f);for(var h,i,j,k=d.getImageData(0,0,e,f).data,l={},m=0;mj&&(i=.35),50>j&&(i=.01),(k[m]>210||k[m+1]>210||k[m+2]>210)&&(i=.5-1e-4*j),l[h]?l[h]=l[h]+i:l[h]=i;var n=null,o=0;for(var p in l)("255,255,255"==p||"0,0,0"==p)&&(l[p]*=.05),l[p]>o&&(n=p,o=l[p]);for(var q=n.split(","),m=0;m20?c-=.015*Math.pow(2.75,hours-20):6.5>hours&&(c-=-.15*Math.pow(1.36,hours)+1.15),a[0]=Math.round(a[0]*c),a[1]=Math.round(a[1]*c),a[2]=Math.round(a[2]*c);var d="rgb("+a[0]+","+a[1]+","+a[2]+")",e={r:a[0]/255,g:a[1]/255,b:a[2]/255},f=getTextColor(e);tabs.update(b,{backgroundColor:d,foregroundColor:f}),b==tabs.getSelected()&&setColor(d,f)})},{timeout:1e3})}function setColor(a,b){for(var c=document.getElementsByClassName("theme-background-color"),d=document.getElementsByClassName("theme-text-color"),e=0;e1?c.classList.add("has-highlight"):c.classList.remove("has-highlight"),isExpandedMode||requestIdleCallback(function(){requestAnimationFrame(function(){c.scrollIntoView({behavior:"smooth"})})},{timeout:1500})}function leaveTabEditMode(a){var b=document.querySelector(".tab-item.selected");if(b&&b.classList.remove("selected"),a&&a.blur){var c=document.querySelector(".tab-item .tab-input:focus");c&&c.blur()}tabGroup.classList.remove("has-selected-tab"),hidesearchbar()}function enterEditMode(a){leaveExpandedMode();var b=getTabElement(a),c=getWebview(a),d=tabs.get(a).url;"about:blank"==d&&(d="");var e=getTabInput(a);b.classList.add("selected"),tabGroup.classList.add("has-selected-tab"),e.value=d,e.focus(),e.select(),showSearchbar(e),showSearchbarResults("",e,null),c.send&&c.send("getKeywordsData")}function rerenderTabElement(a){var b=getTabElement(a),c=tabs.get(a),d=c.title||"New Tab",e=b.querySelector(".tab-view-contents .title");e.textContent=d,e.title=d;var f=b.getElementsByClassName("icon-tab-not-secure")[0];if(c.secure===!1){if(!f){var g=b.querySelector(".tab-icon-area");g.insertAdjacentHTML("afterbegin","")}}else f&&f.parentNode.removeChild(f);bookmarks.renderStar(a)}function createTabElement(a){var b=tabs.get(a),c=urlParser.parse(b.url),d=document.createElement("div");d.className="tab-item",d.setAttribute("data-tab",a),b["private"]&&d.classList.add("private-tab");var e=document.createElement("div");e.className="tab-edit-contents";var f=document.createElement("input");f.className="tab-input mousetrap",f.setAttribute("placeholder","Search or enter address"),f.value=c,e.appendChild(f),e.appendChild(bookmarks.getStar(a)),d.appendChild(e);var g=document.createElement("div");g.className="tab-view-contents",g.appendChild(readerView.getButton(a));var h=document.createElement("span");h.className="tab-icon-area",b["private"]&&(h.insertAdjacentHTML("afterbegin",""),g.setAttribute("title","Private tab")),g.appendChild(h);var i=document.createElement("span");return i.className="title",i.textContent=b.title||"New Tab",g.appendChild(i),g.insertAdjacentHTML("beforeend",""),d.appendChild(g),f.addEventListener("keydown",function(a){(9==a.keyCode||40==a.keyCode)&&(focussearchbarItem(),a.preventDefault())}),f.addEventListener("keyup",function(a){8==a.keyCode&&showSearchbarResults(this.value,this,a)}),f.addEventListener("keypress",function(a){if(13==a.keyCode)openURLFromsearchbar(a,this.value),getWebview(tabs.getSelected()).focus();else{if(9==a.keyCode)return;if(16==a.keyCode)return;if(8==a.keyCode)return;showSearchbarResults(this.value,this,a)}var b=String.fromCharCode(a.keyCode).toLowerCase(),c=this.value.substring(this.selectionStart,this.selectionEnd).indexOf(b);b&&0==c&&(this.selectionStart+=1,a.preventDefault())}),f.addEventListener("click",function(a){a.stopPropagation()}),d.addEventListener("click",function(a){var b=this.getAttribute("data-tab");tabs.getSelected()!=b?switchToTab(b):isExpandedMode||enterEditMode(b)}),d.addEventListener("mousewheel",function(a){if(a.deltaY>65&&a.deltaX<10&&Date.now()-lastTabDeletion>650){if(lastTabDeletion=Date.now(),isFocusMode)return void showFocusModeError();var b=this.getAttribute("data-tab");this.style.transform="translateY(-100%)",setTimeout(function(){if(b==tabs.getSelected()){var a=tabs.getIndex(tabs.getSelected()),c=tabs.getAtIndex(a-1)||tabs.getAtIndex(a+1);destroyTab(b),c?switchToTab(c.id):addTab()}else destroyTab(b)},150)}}),d.addEventListener("mouseenter",handleExpandedModeTabItemHover),d}function addTab(a,b){b=b||{},0!=b.leaveEditMode&&leaveTabEditMode(),a=a||tabs.add();var c=tabs.get(a);c["private"]&&!c.backgroundColor?tabs.update(a,{backgroundColor:defaultColors["private"][0],foregroundColor:defaultColors["private"][1]}):c.backgroundColor||tabs.update(a,{backgroundColor:defaultColors.regular[0],foregroundColor:defaultColors.regular[1]}),findinpage.end();var d=tabs.getIndex(a),e=createTabElement(a);tabGroup.insertBefore(e,tabGroup.childNodes[d]),addWebview(a),b.openInBackground||(switchToTab(a,{focusWebview:!1}),0!=b.enterEditMode&&enterEditMode(a))}function handleExpandedModeTabItemHover(a){if(isExpandedMode){var b=this;setTimeout(function(){b.matches(":hover")&&switchToTab(b.getAttribute("data-tab"))},125)}}function enterExpandedMode(){isExpandedMode||(dragRegion.containers=[tabDragArea],leaveTabEditMode(),tabs.get().forEach(function(a){var b=urlParser.prettyURL(a.url);console.log(a),getTabElement(a.id).querySelector(".secondary-text").textContent=b}),requestAnimationFrame(function(){document.body.classList.add("is-expanded-mode"),tabContainer.focus()}),isExpandedMode=!0)}function leaveExpandedMode(){isExpandedMode&&(dragRegion.containers=[],document.body.classList.remove("is-expanded-mode"),isExpandedMode=!1)}function addPrivateTab(){if(isFocusMode)return void showFocusModeError();isEmpty(tabs.get())&&destroyTab(tabs.getAtIndex(0).id);var a=tabs.getIndex(tabs.getSelected())+1,b=tabs.add({url:"about:blank","private":!0},a);addTab(b)}function showFocusModeError(){electron.remote.require("dialog").showMessageBox({type:"info",buttons:["OK"],message:"You're in focus mode.",detail:'You can leave focus mode by unchecking "focus mode" in the view menu.'})}require("require.async")(require),window.electron=require("electron"),window.ipc=electron.ipcRenderer,window.remote=electron.remote,window.Dexie=require("dexie"),window.addEventListener("drop",function(a){a.preventDefault()}),ipc.on("enter-full-screen",function(){document.body.classList.add("fullscreen")}),ipc.on("leave-full-screen",function(){document.body.classList.remove("fullscreen")}),window.addEventListener("load",function(a){"MacIntel"!=navigator.platform&&document.body.classList.add("notMac")});var db=new Dexie("browsingData");db.version(2).stores({bookmarks:"url, title, text, extraData",history:"url, title, color, visitCount, lastVisit, extraData",readingList:"url, time, visitCount, pageHTML, article, extraData"}),db.version(3).stores({bookmarks:"url, title, text, extraData",history:"url, title, color, visitCount, lastVisit, extraData",readingList:"url, time, visitCount, pageHTML, article, extraData",settings:"key, value"}),db.open().then(function(){console.log("database opened ",performance.now())}),Dexie.Promise.on("error",function(a){console.warn("database error occured",a)});var tabs={_state:{tabs:[],selected:null},add:function(a,b){if(!a)var a={};var c=a.id||Math.round(1e17*Math.random()),d={url:a.url||"",title:a.title||"",id:c,lastActivity:a.lastActivity||Date.now(),secure:a.secure,"private":a["private"]||!1,readerable:a.readerable||!1,backgroundColor:a.backgroundColor,foregroundColor:a.foregroundColor};return b?tabs._state.tabs.splice(b,0,d):tabs._state.tabs.push(d),c},update:function(a,b){if(!tabs.get(a))throw new ReferenceError("Attempted to update a tab that does not exist.");for(var c=-1,d=0;d0},parse:function(a){if(a=a.trim(),!a)return"about:blank";if(urlParser.isURL(a))return a;if(0==a.indexOf("view-source:")){var b=a.replace("view-source:","");return"view-source:"+urlParser.parse(b)}return urlParser.isURLMissingProtocol(a)?"http://"+a:urlParser.searchBaseURL.replace("%s",encodeURIComponent(a))},prettyURL:function(a){var b=new URL(a);return(b.hostname+b.pathname).replace(urlParser.startingWWWRegex,"$1").replace(urlParser.trailingSlashRegex,"")},areEqual:function(a,b){try{var c=new URL(a),d=new URL(b);return c.hostname==d.hostname&&c.pathname==d.pathname}catch(e){return a==b}}},setFilteringSettings=remote.getGlobal("setFilteringSettings"),registerFiltering=remote.getGlobal("registerFiltering");db.settings.where("key").equals("filtering").first(function(a){setFilteringSettings(a.value)});var phishingWarningPage="file://"+__dirname+"/pages/phishing/index.html",crashedWebviewPage="file:///"+__dirname+"/pages/crash/index.html",errorPage="file:///"+__dirname+"/pages/error/index.html",webviewBase=document.getElementById("webviews"),webviewEvents=[],webviewIPC=[];remote.session.defaultSession.setPermissionRequestHandler(pagePermissionRequestHandler);var WebviewsWithHiddenClass=!1,Menu=remote.Menu,MenuItem=remote.MenuItem,clipboard=remote.clipboard,webviewMenu={cache:{event:null,webview:null},loadFromContextData:function(a){var b=tabs.get(tabs.getSelected()),c=webviewMenu.cache.event,d=new Menu;if(a.src&&!isFocusMode){if(a.src.length>60)var e=a.src.substring(0,60)+"...";else var e=a.src;d.append(new MenuItem({label:e,enabled:!1})),d.append(new MenuItem({label:"Open in New Tab",click:function(){var c=tabs.add({url:a.src,"private":b["private"]},tabs.getIndex(tabs.getSelected())+1);addTab(c,{enterEditMode:!1}),getWebview(c).focus()}})),b["private"]||d.append(new MenuItem({label:"Open in New Private Tab",click:function(){var b=tabs.add({url:a.src,"private":!0},tabs.getIndex(tabs.getSelected())+1);addTab(b,{enterEditMode:!1}),getWebview(b).focus()}})),d.append(new MenuItem({type:"separator"})),d.append(new MenuItem({label:"Copy link",click:function(){clipboard.writeText(a.src)}}))}a.selection&&(d.append(new MenuItem({label:"Copy",click:function(){clipboard.writeText(a.selection)}})),d.append(new MenuItem({type:"separator"})),d.append(new MenuItem({label:"Search with DuckDuckGo",click:function(){var c=tabs.add({url:"https://duckduckgo.com/?t=min&q="+encodeURIComponent(a.selection),"private":b["private"]});addTab(c,{enterEditMode:!1}),getWebview(c).focus()}}))),a.image&&d.append(new MenuItem({label:"View image",click:function(){navigate(webviewMenu.cache.tab,a.image)}})),d.append(new MenuItem({label:"Inspect Element",click:function(){webviewMenu.cache.webview.inspectElement(c.x,c.y)}})),d.popup(remote.getCurrentWindow())},show:function(a){var b=a.originalEvent||a;webviewMenu.cache.event=b;var c=tabs.getSelected(),d=getWebview(c);webviewMenu.cache.tab=c,webviewMenu.cache.webview=d,d.send("getContextData",{x:b.offsetX,y:b.offsetY})}};bindWebviewIPC("contextData",function(a,b,c){webviewMenu.loadFromContextData(c[0])});var bookmarks={updateHistory:function(a){setTimeout(function(){var b=tabs.get(a);if(b){var c={url:b.url,title:b.title,color:b.backgroundColor};bookmarks.historyWorker.postMessage({action:"updateHistory",data:c})}},500)},currentCallback:function(){},onDataRecieved:function(a){bookmarks.bookmarksWorker.postMessage({action:"addBookmark",data:a})},deleteBookmark:function(a){bookmarks.bookmarksWorker.postMessage({action:"deleteBookmark",data:{url:a}})},deleteHistory:function(a){bookmarks.historyWorker.postMessage({action:"deleteHistory",data:{url:a}})},searchBookmarks:function(a,b){bookmarks.currentCallback=b,bookmarks.bookmarksWorker.postMessage({action:"searchBookmarks",text:a})},searchHistory:function(a,b){bookmarks.currentHistoryCallback=b,bookmarks.historyWorker.postMessage({action:"searchHistory",text:a})},getHistorySuggestions:function(a,b){bookmarks.currentHistoryCallback=b,bookmarks.historyWorker.postMessage({action:"getHistorySuggestions",text:a})},onMessage:function(a){"bookmarks"==a.data.scope?bookmarks.currentCallback(a.data.result):"history"==a.data.scope&&bookmarks.currentHistoryCallback(a.data.result)},bookmark:function(a){getWebview(a).send("sendData")},toggleBookmarked:function(a){var b=tabs.get(a).url,c=!1;bookmarks.searchBookmarks(b,function(d){d.forEach(function(a){a.url==b&&(c=!0)}),c?(console.log("deleting bookmark "+tabs.get(a).url),bookmarks.deleteBookmark(tabs.get(a).url)):bookmarks.bookmark(a)})},handleStarClick:function(a){a.classList.toggle("fa-star"),a.classList.toggle("fa-star-o"),bookmarks.toggleBookmarked(a.getAttribute("data-tab"))},getStar:function(a){var b=document.createElement("i");return b.setAttribute("data-tab",a),b.className="fa fa-star-o bookmarks-button theme-text-color",b.addEventListener("click",function(a){bookmarks.handleStarClick(a.target)}),bookmarks.renderStar(a,b)},renderStar:function(a,b){b=b||document.querySelector('.bookmarks-button[data-tab="{id}"]'.replace("{id}",a));var c=tabs.get(a).url;return c&&"about:blank"!=c?(b.hidden=!1,bookmarks.searchBookmarks(c,function(a){if(a){var d=!1;a.forEach(function(a){a.url==c&&(d=!0)}),d?(b.classList.remove("fa-star-o"),b.classList.add("fa-star")):(b.classList.remove("fa-star"),b.classList.add("fa-star-o"))}}),b):(b.hidden=!0,b)},init:function(){bookmarks.historyWorker=new Worker("js/bookmarksHistory/historyWorker.js"),bookmarks.historyWorker.onmessage=bookmarks.onMessage,bookmarks.bookmarksWorker=new Worker("js/bookmarksHistory/bookmarksWorker.js"),bookmarks.bookmarksWorker.onmessage=bookmarks.onMessage}};bookmarks.init();var trailingSlashRegex=/\/$/g,plusRegex=/\+/g,lastItemDeletion=Date.now(),searchbar=document.getElementById("searchbar"),showSearchbarResults=function(a,b,c){if(c&&8!=c.keyCode)var d=a.substring(0,b.selectionStart)+String.fromCharCode(c.keyCode)+a.substring(b.selectionEnd,a.length);else var d=a;console.log("searchbar: ",d),runPlugins(d,b,c)};searchbar.addEventListener("keydown",function(a){13==a.keyCode?a.target.click():9==a.keyCode||40==a.keyCode?(a.preventDefault(),focussearchbarItem()):38==a.keyCode&&(a.preventDefault(),focussearchbarItem({focusPrevious:!0}))}),bindWebviewIPC("keywordsData",function(a,b,c){ var d=c[0],e=0,f=[],g=getSearchbarContainer("searchSuggestions");d.entities.forEach(function(a,b){if(/\s/g.test(a.trim())&&!(e>=5||-1!=f.indexOf(a.trim()))){var c=createSearchbarItem({icon:"fa-search",title:a,classList:["iadata-onfocus"]});c.addEventListener("click",function(b){b.metaKey?openURLInBackground(a):navigate(tabs.getSelected(),a)}),g.appendChild(c),e++,f.push(a.trim())}})});var searchbarPlugins=[],searchbarResultCount=0,hasAutocompleted=!1,topAnswerArea=searchbar.querySelector(".top-answer-area");registerSearchbarPlugin("history",{index:1,trigger:function(a){return!!a&&0!=a.indexOf("!")},showResults:throttle(showSearchbarHistoryResults,50)}),registerSearchbarPlugin("instantAnswers",{index:2,trigger:function(a){return a.length>3&&!urlParser.isURLMissingProtocol(a)&&!tabs.get(tabs.getSelected())["private"]},showResults:debounce(showSearchbarInstantAnswers,400)});var instantAnswers={color_code:function(a,b){var c=[b.data.rgb,b.data.hslc,b.data.cmyb];a.startsWith("#")||c.unshift(b.data.hexc);var d=createSearchbarItem({title:a,descriptionBlock:c.join(" · "),attribution:ddgAttribution}),e=document.createElement("div");return e.className="result-icon color-circle",e.style.backgroundColor="#"+b.data.hex_code,d.insertBefore(e,d.firstChild),d},minecraft:function(a,b){var c=createSearchbarItem({title:b.data.title,image:b.data.image,descriptionBlock:b.data.description+" "+b.data.subtitle,attribution:ddgAttribution});return c},figlet:function(a,b){var c=removeTags(b).replace("Font: standard",""),d=createSearchbarItem({descriptionBlock:c,attribution:ddgAttribution}),e=d.querySelector(".description-block");return e.style.whiteSpace="pre-wrap",e.style.fontFamily="monospace",e.style.maxHeight="10em",e.style.webkitUserSelect="auto",d},currency_in:function(a,b){var c="";if("string"==typeof b)c=b;else{var d=[];for(var e in b.data.record_data)d.push(b.data.record_data[e]+" ("+e+")");c=d.join(", ")}if(b.data)var f=b.data.title;else var f="Answer";var g=createSearchbarItem({title:c,descriptionBlock:f,attribution:ddgAttribution});return g}};registerSearchbarPlugin("bookmarks",{index:3,trigger:function(a){return a.length>4},showResults:debounce(showBookmarkResults,200)});var stringScore=require("string_score"),searchOpenTabs=function(a,b,c,d){empty(d);var e=[],f=tabs.getSelected();if(tabs.get().forEach(function(b){if(b.id!=f&&b.title&&"about:blank"!=b.url){var c=urlParser.removeProtocol(b.url),d=-1!=b.title.indexOf(a)||-1!=c.indexOf(a),g=b.title.substring(0,50).score(a,.5)>.4||c.score(a,.5)>.4;(d||g)&&e.push(b)}}),0!=e.length){var g=e.splice(0,2).sort(function(b,c){return c.title.score(a,.5)-b.title.score(a,.5)});g.forEach(function(a){var b={icon:"fa-external-link-square",title:a.title,secondaryText:urlParser.removeProtocol(a.url).replace(trailingSlashRegex,"")},c=createSearchbarItem(b);c.addEventListener("click",function(){var b=tabs.get(tabs.getSelected()).url;b&&"about:blank"!=b||destroyTab(tabs.getSelected(),{switchToTab:!1}),switchToTab(a.id)}),d.appendChild(c)}),searchbarResultCount+=g.length}};registerSearchbarPlugin("openTabs",{index:4,trigger:function(a){return a.length>2},showResults:searchOpenTabs});var ddgAttribution="Results from DuckDuckGo",bangRegex=/!\w+/g,cachedBangSnippets={},bangUseCounts=JSON.parse(localStorage.getItem("bangUseCounts")||"{}"),saveBangUseCounts=debounce(function(){localStorage.setItem("bangUseCounts",JSON.stringify(bangUseCounts))},1e4);registerSearchbarPlugin("searchSuggestions",{index:3,trigger:function(a){return!!a&&!tabs.get(tabs.getSelected())["private"]},showResults:debounce(showSearchSuggestions,200)}),registerSearchbarPlugin("historySuggestions",{index:1,trigger:function(a){return!a},showResults:showHistorySuggestions});var readerView={readerURL:"file://"+__dirname+"/reader/index.html",getReaderURL:function(a){return readerView.readerURL+"?url="+a},getButton:function(a){var b=document.createElement("i");return b.className="fa fa-align-left reader-button",b.setAttribute("data-tab",a),b.setAttribute("title","Enter reader view"),b.addEventListener("click",function(a){var b=this.getAttribute("data-tab"),c=tabs.get(b);a.stopPropagation(),c.isReaderView?readerView.exit(b):readerView.enter(b)}),b},updateButton:function(a){var b=document.querySelector('.reader-button[data-tab="{id}"]'.replace("{id}",a)),c=tabs.get(a);return c.isReaderView?(b.classList.add("is-reader"),void b.setAttribute("title","Exit reader view")):(b.classList.remove("is-reader"),b.setAttribute("title","Enter reader view"),void(c.readerable?b.classList.add("can-reader"):b.classList.remove("can-reader")))},enter:function(a){navigate(a,readerView.readerURL+"?url="+tabs.get(a).url),tabs.update(a,{isReaderView:!0})},exit:function(a){navigate(a,tabs.get(a).url.split("?url=")[1]),tabs.update(a,{isReaderView:!1})},showReadingList:function(a){showSearchbar(getTabInput(tabs.getSelected()));var b=0,c=!1;db.readingList.orderBy("time").reverse().each(function(d){if(d.article){if(a&&a.limitResults&&b>3)return void(c=!0);0==b&&clearSearchbar();var e=createSearchbarItem({title:d.article.title,descriptionBlock:d.article.excerpt,url:d.url,"delete":function(a){db.readingList.where("url").equals(a.getAttribute("data-url"))["delete"]()}});e.addEventListener("click",function(a){openURLFromsearchbar(a,readerView.getReaderURL(d.url))}),(d.visitCount>5||d.extraData.scrollPosition>0&&d.extraData.articleScrollLength-d.extraData.scrollPosition<1e3)&&(e.style.opacity=.65),getSearchbarContainer("history").appendChild(e),b++}}).then(function(){if(0==b){var a=createSearchbarItem({title:"Your reading list is empty.",descriptionBlock:"Articles you open in reader view are listed here, and are saved offline for 30 days."});return void historyarea.appendChild(a)}if(c){var d=createSearchbarItem({title:"More articles"});d.style.opacity=.5,d.addEventListener("click",function(a){clearSearchbar(),readerView.showReadingList({limitResults:!1})}),historyarea.appendChild(d)}})}};bindWebviewEvent("did-finish-load",function(a){var b=this.getAttribute("data-tab"),c=this.getAttribute("src");0==c.indexOf(readerView.readerURL)?tabs.update(b,{isReaderView:!0,readerable:!1}):tabs.update(b,{isReaderView:!1,readerable:!1}),readerView.updateButton(b)}),bindWebviewIPC("canReader",function(a,b){tabs.update(b,{readerable:!0}),readerView.updateButton(b)});var tabActivity={minFadeAge:33e4,refresh:function(){requestAnimationFrame(function(){var a=tabs.get(),b=tabs.getSelected(),c=Date.now();a.forEach(function(a){return b==a.id?void getTabElement(a.id).classList.remove("fade"):void(c-a.lastActivity>tabActivity.minFadeAge?getTabElement(a.id).classList.add("fade"):getTabElement(a.id).classList.remove("fade"))})})},init:function(){setInterval(tabActivity.refresh,7500)}};tabActivity.init();var colorExtractorImage=document.createElement("img");const defaultColors={"private":["rgb(58, 44, 99)","white"],regular:["rgb(255, 255, 255)","black"]};var hours=(new Date).getHours()+(new Date).getMinutes()/60;setInterval(function(){var a=new Date;hours=a.getHours()+a.getMinutes()/60},24e4);var getTextColor=function(a){var b=runNetwork(a);return b.black>.5?"black":"white"},runNetwork=function(a){for(var b={layers:[{r:{},g:{},b:{}},{0:{bias:14.176907520571566,weights:{r:-3.2764240497480652,g:-16.90247884718719,b:-2.9976364179397814}},1:{bias:9.086071102351246,weights:{r:-4.327474143397604,g:-15.780660155750773,b:2.879230202567851}},2:{bias:22.274487339773476,weights:{r:-3.5830205067960965,g:-25.498384261673618,b:-6.998329189107962}}},{black:{bias:17.873962570788997,weights:{0:-15.542217788633987,1:-13.377152708685674,2:-24.52215186113144}}}],outputLookup:!0,inputLookup:!0},c=1;cb;b++)!function(b){a.bind("mod+"+b,function(a){var c=tabs.getIndex(tabs.getSelected()),d=tabs.getAtIndex(c+b)||tabs.getAtIndex(c-b);d&&switchToTab(d.id)}),a.bind("shift+mod+"+b,function(a){var c=tabs.getIndex(tabs.getSelected()),d=tabs.getAtIndex(c-b)||tabs.getAtIndex(c+b);d&&switchToTab(d.id)})}(b);a.bind("mod+9",function(a){switchToTab(tabs.getAtIndex(tabs.count()-1).id)}),a.bind("shift+mod+9",function(a){switchToTab(tabs.getAtIndex(0).id)}),a.bind("esc",function(a){leaveTabEditMode(),leaveExpandedMode(),findinpage.isEnabled?findinpage.end():getWebview(tabs.getSelected()).focus()}),a.bind("shift+mod+r",function(){var a=tabs.get(tabs.getSelected());a.isReaderView?readerView.exit(a.id):readerView.enter(a.id)}),a.bind("mod+left",function(a){getWebview(tabs.getSelected()).goBack()}),a.bind("mod+right",function(a){getWebview(tabs.getSelected()).goForward()}),a.bind(["option+mod+left","shift+ctrl+tab"],function(a){enterExpandedMode();var b=tabs.getIndex(tabs.getSelected()),c=tabs.getAtIndex(b-1);switchToTab(c?c.id:tabs.getAtIndex(tabs.count()-1).id)}),a.bind(["option+mod+right","ctrl+tab"],function(a){enterExpandedMode();var b=tabs.getIndex(tabs.getSelected()),c=tabs.getAtIndex(b+1);switchToTab(c?c.id:tabs.getAtIndex(0).id)}),a.bind("mod+n",function(a){for(var b=tabs.get(),c=0;c1)var b=" matches";else var b=" match";findinpage.counter.textContent=a.result.matches+b}});var sessionRestore={save:function(){requestIdleCallback(function(){var a={version:1,tabs:[],selected:tabs._state.selected};tabs.get().forEach(function(b){b["private"]||a.tabs.push(b)}),localStorage.setItem("sessionrestoredata",JSON.stringify(a))},{timeout:2250})},restore:function(){try{var a=localStorage.getItem("sessionrestoredata");if(!a){var b=tabs.add({url:"https://palmeral.github.io/min/tour"});return void addTab(b,{enterEditMode:!1})}if(a=JSON.parse(a),localStorage.setItem("sessionrestoredata","{}"),a.version&&1!=a.version)return void addTab(tabs.add(),{leaveEditMode:!1});if(console.info("restoring tabs",a.tabs),isEmpty(a.tabs))return void addTab(tabs.add(),{leaveEditMode:!1});a.tabs.forEach(function(a,b){var c=tabs.add(a);addTab(c,{openInBackground:!0,leaveEditMode:!1,focus:!1})}),switchToTab(tabs.get(a.selected)?a.selected:a.tabs[0].id)}catch(c){console.warn("failed to restore session, rolling back"),console.error(c),localStorage.setItem("sessionrestoredata","{}"),setTimeout(function(){window.location.reload()},500)}}};sessionRestore.restore(),setInterval(sessionRestore.save,12500);var isFocusMode=!1;ipc.on("enterFocusMode",function(){isFocusMode=!0,document.body.classList.add("is-focus-mode"),setTimeout(function(){electron.remote.require("dialog").showMessageBox({type:"info",buttons:["OK"],message:"You're in focus mode.",detail:'In focus mode, all tabs except the current one are hidden, and you can\'t create new tabs. You can leave focus mode by unchecking "focus mode" from the view menu.'})},16)}),ipc.on("exitFocusMode",function(){isFocusMode=!1,document.body.classList.remove("is-focus-mode")}); \ No newline at end of file diff --git a/dist/webview.min.js b/dist/webview.min.js index 7a14d9b93..3d80b8db6 100644 --- a/dist/webview.min.js +++ b/dist/webview.min.js @@ -1,2 +1,2 @@ -/*! 04-10-2016 */ +/*! 04-11-2016 */ function getBookmarksText(a,b){var c=a.cloneNode(a,!0),d=c.body.querySelectorAll('link, style, script, noscript, .visually-hidden, .visuallyhidden, [role=presentation], [hidden], [style*="display:none"], .ad, .dialog, .modal');if(d)for(var e=0;e/g,"")}function debug_phishing(a){console.log(a)}function checkPhishingStatus(){function a(a){if(a.querySelector("input[type=password]"))return debug_phishing("form with password input found"),t=!0,!0;if(2==a.querySelectorAll("input[type=text], input[type=password]").length)return debug_phishing("possibly sensitive form, checking but increasing minScore"),j*=1.5,t=!0,!0;if(!a.querySelector("input"))return debug_phishing("empty form found, checking but not counting as sensitive"),j+=.35,!0;for(var b=a.textContent.toLowerCase(),c=0;c25&&(debug_phishing("long hostname detected"),k+=.0075*window.location.host.length),h.split("?")[0].length>75&&(debug_phishing("long window location detected"),k+=Math.min(1e-4*window.location.toString().length,.2)),h.split("/").length>5&&(debug_phishing("long path found"),k+=Math.max(.05*h.split("/").length,.25)),window.location.hostname.split(".").length>3&&window.location.hostname.length>20&&(debug_phishing("high number of . characters detected"),k+=Math.min(.03*h.split("?")[0].split(".").length,.2)),window.location.pathname.length>25&&(debug_phishing("paths detected"),k+=Math.min(.05+.002*window.location.pathname.length,.3)),o&&window.location.pathname.length<20&&window.location.hostname.replace("www.","").length<18&&(debug_phishing("short root domain found, increasing minScore"),j+=.3+.05*(18-window.location.hostname.length)-.01*window.location.pathname.length);var m=["com","org","edu","mil","gov"],n=window.location.hostname.split(".").reverse()[0],o=-1!=m.indexOf(n);window.location.hostname&&!o&&(k+=.15,debug_phishing("unusual domain ending found, increasing score")),d.forEach(function(a){-1!=h.toLowerCase().indexOf(a)&&(debug_phishing("detected sensitive word found in location"),k+=.025)});var p=document.querySelectorAll("form"),q=0,r=!1,s=!1,t=!1;if(p){for(var g=0;gx?(debug_phishing("form with simple path for action detected"),s=!0):3>x&&(debug_phishing("non-absolute form path detected"),k+=.1),-1!=w.indexOf(".php")&&(debug_phishing("php file action found"),k+=.075),l.href=w,0!=w.indexOf("javascript:")&&b(l.hostname)!=b(window.location.hostname)&&(debug_phishing("submitting form to xdomain"),k+=.7),"https:"!=l.protocol&&(debug_phishing("submitting form without https"),k+=.15),d.forEach(function(a){-1!=v.indexOf(a)&&(debug_phishing("sensitive word found in form"),k+=.02)})}else debug_phishing("form without action detected"),r=!0}}1==r&&(k+=.4,k+=Math.min(.2,1e-4*q)),1==s&&(k+=.75)}t||document.querySelector("input[type=password]")||(debug_phishing("no sensitive forms found, increasing minScore"),j+=.33);for(var y=document.querySelectorAll("a, area[href]"),z={},A={},B=0,C=0,g=0;g4&&H&&z[H]/F>.25){debug_phishing("found "+z[H]+" links that point to domain "+H),k+=Math.min(.1*z[H],.25);break}}else E+=z[H];(F>2&&0==E||F>5&&.15>E/F)&&(debug_phishing("links go to external domain"),k+=Math.min(.1+.1*(F-E),.5)),(B>9||F>2&&B/F>.5)&&(debug_phishing("counted "+B+" empty links"),k+=Math.min(.02*B,.2)),C>3&&(debug_phishing("counted "+C+" javascript links"),k+=.1);var I=i.length;q>50&&1e3>q&&.075>q/I?(debug_phishing("forms are very minor part of page, increasing minScore"),j+=Math.min(1.15-q/I,1.2)):q>50&&3500>q&&.14>q/I&&(debug_phishing("forms are minor part of page, increasing minScore (small)"),debug_phishing(q),debug_phishing(I),j+=.25);var J=document.querySelectorAll("script"),K={},L=0;if(J)for(var g=0;g2&&K[N]/L>.75&&K[N]<.95&&(k+=.1,debug_phishing("external scripts found, increasing score")),M=K[N];p.length>3&&(debug_phishing("many forms found, increasing minScore"),j+=Math.min(.05*p.length,.2)),document.body.innerHTML.length<4500&&(debug_phishing("small amount of body text, multiplying score"),k*=1.4);var O=document.querySelector('link[rel="shortcut icon"]');O&&O.href&&(l.href=O.href,b(l.hostname)!=G&&(debug_phishing("icon from external domain found"),k+=.1));var P=document.querySelectorAll("p");P.length>50&&(debug_phishing("many paragraphs found, increasing minScore"),j+=.1+Math.min(.025*P.length,.2)),console.log("min "+j),console.log("status",k),k>j&&ipc.sendToHost("phishingDetected");var Q=performance.now();return console.log("phishing scan took "+(Q-c)+" milliseconds"),!0}function getReaderScore(){var a=document.querySelectorAll("p"),b=0;if(a){for(var c=0;c_browser_zoomLevel&&(_browser_zoomLevel+=1),webFrame.setZoomLevel(_browser_zoomLevel)}function zoomOut(){webFrame||(webFrame=electron.webFrame),_browser_zoomLevel>_browser_minZoom&&(_browser_zoomLevel-=1),webFrame.setZoomLevel(_browser_zoomLevel)}function zoomReset(){webFrame||(webFrame=electron.webFrame),_browser_zoomLevel=0,webFrame.setZoomLevel(_browser_zoomLevel)}function isScrolledIntoView(a){var b=a.getBoundingClientRect().top,c=a.getBoundingClientRect().bottom,d=b=0;return d}var electron=require("electron"),ipc=electron.ipcRenderer,webFrame;ipc.on("sendData",function(){var a,b,c,d,e=document.querySelector("[itemprop=price], .price, .offer-price, #priceblock_ourprice, .discounted-price"),f=document.querySelector("[itemprop=priceCurrency], [property=priceCurrency]");e&&(a=e.textContent),/\d/g.test(a)||(a=void 0),a&&-1==a.indexOf("$")&&f&&"en-US"==navigator.language&&(a=(f.content||f.textContent).replace("USD","$")+a);var g=document.querySelector('.star-img, .rating, [itemprop="ratingValue"], [property="ratingValue"]');g||(g=document.querySelector('[class^="rating"], [class^="review"]')),g&&(b=g.title||g.alt||g.content||g.textContent,b=b.replace("rating","").replace("stars","").replace("star","").trim(),console.log("r: "+b),b&&/\d+$/g.test(b)&&(b+=" stars"));var h=document.querySelector('[itemprop="location"], [itemprop="address"]');if(!h)var h=document.querySelector(".adr, .addr, .address");h&&(c=h.textContent.trim()),c&&/,?\d{5}$/g.test(c)&&(c=c.replace(/,?\d{5}$/g,""));var i=document.querySelector('[itemprop="totalTime"], [itemprop="cookTime"]');i&&(d=i.textContent,d=d.replace(/\sm$/g," minutes").replace(/\sh$/g," hours"),d=d.replace("1 hours","1 hour")),console.log("rating: "+b),console.log("price: "+a),console.log("location: "+c);for(var j=getBookmarksText(document,window),k=document.querySelectorAll("iframe"),l=0;l650||document.querySelector("article")&&b>200)&&(setTimeout(function(){ipc.sendToHost("canReader")},500),setTimeout(function(){ipc.sendToHost("canReader")},2500))});var totalMouseMove=0,verticalMouseMove=0,eventsCaptured=0,documentUnloaded=!1;window.addEventListener("mousewheel",function(a){return verticalMouseMove+=a.deltaY,eventsCaptured++,verticalMouseMove>55&&a.metaKey&&eventsCaptured>1?(verticalMouseMove=-10,zoomOut()):-55>verticalMouseMove&&a.metaKey&&eventsCaptured>1?(verticalMouseMove=-10,zoomIn()):void(a.deltaY>5||a.deltaY<-10||documentUnloaded||(totalMouseMove+=a.deltaX,-150>totalMouseMove?(doneNavigating=!0,window.history.back(),documentUnloaded=!0,setTimeout(function(){documentUnloaded=!1},3e3)):totalMouseMove>100&&(documentUnloaded=!0,window.history.go(1),setTimeout(function(){documentUnloaded=!1},3e3))))}),setInterval(function(){totalMouseMove=0},4e3),setInterval(function(){verticalMouseMove=0,eventsCaptured=0},1e3);var _browser_zoomLevel=0,_browser_maxZoom=9,_browser_minZoom=-8;ipc.on("zoomIn",zoomIn),ipc.on("zoomOut",zoomOut),ipc.on("zoomReset",zoomReset),ipc.on("getKeywordsData",function(a){function b(a){for(var b=["LINK","STYLE","SCRIPT","NOSCRIPT","svg","symbol","title","path","style"],c="",d=a.querySelectorAll("p, h2, h3, h4, li, [name=author], [itemprop=name], .article-author"),e=window.scrollY,f=0;f500||d[f].textContent.length<50||d[f].querySelector("time, span, div, menu"))&&-1==b.indexOf(g.tagName)){var h=g.textContent||g.content;c+=d[f-1]&&/\.\s*$/g.test(d[f-1].textContent)?" "+h:". "+h}}return c=c.replace(/[\n\t]/g,"")}if(!(getReaderScore()<400&&-1==window.location.toString().indexOf("reader/index.html"))){var c=b(document),d=document.querySelectorAll("iframe");if(d)for(var e=0;e