Skip to content

Instantly share code, notes, and snippets.

@horiacristescu
Last active April 3, 2018 04:48
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save horiacristescu/e6597edcb7ec6993521829ef5c1798db to your computer and use it in GitHub Desktop.
Save horiacristescu/e6597edcb7ec6993521829ef5c1798db to your computer and use it in GitHub Desktop.
Text to Speech Bookmarklet
Make a bookmarklet with this code:
javascript:!function(e){function t(u){if(n[u])return n[u].exports;var r=n[u]={exports:{},id:u,loaded:!1};return e[u].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){function u(){}function r(e){console.log("pageX",e.pageX,"pageY",e.pageY),T("#speaker").css({left:e.pageX-T("#speaker").width()/2+15,top:e.pageY-T("#speaker").height()/2+15,display:"block",width:"100px",height:"100px","margin-left":"-30px","margin-top":"-30px",opacity:"1"}),T("#speaker").each(function(e,t){T(t).animate({opacity:0,left:"+="+T(t).width()/4,top:"+="+T(t).height()/4,height:0,width:0},500,function(){T(t).hide()})})}function i(e,t,n){if("SCRIPT"!=e.tagName&&"math"!=e.tagName&&"CODE"!=e.tagName&&"BUTTON"!=e.tagName&&"STYLE"!=e.tagName&&"ASIDE"!=e.tagName&&"PRE"!=e.tagName){var u=T(e).css("float"),r="left"==u||"right"==u;if(!(T(e).width()<500&&r)){if(e.classList)for(var o=0;o<e.classList.length;o++){if("word"==e.classList[o]||"MathJax"==e.classList[o]||"ltx_ERROR"==e.classList[o]||"mjx-math"==e.classList[o]||"math"==e.classList[o])return;if(n&&n(e.classList[o]))return}for(var a=e.firstChild;null!==a;a=a.nextSibling)3===a.nodeType&&a.textContent.match("[^ ]")?(e.collectNodesCompleted=!0,t.push(a)):1===a.nodeType&&i(a,t,n)}}}function o(){var e=document.createElement("iframe");e.setAttribute("src","https://horia.com/dist/xdmessage.html"),e.style.width="1px",e.style.height="1px",document.body.appendChild(e),window.comm_frame=e}function a(e){comm_frame.contentWindow.postMessage(e,"https://horia.com/")}function s(){return enVoices=["Ava","Alex","Tom","Samantha","Google US English"],_.voiceCounter=(_.voiceCounter+1)%enVoices.length,enVoices[voiceCounter]}function l(e){var t=document.activeElement.tagName;"INPUT"!=t&&"TEXTAREA"!=t&&(32==e.keyCode&&(e.preventDefault(),"keyup"==e.type&&window.isSpeaking&&f()),e.keyCode=="V".charCodeAt(0)&&(e.preventDefault(),"keyup"==e.type&&(_.defaultVoice=s(),console.log("New voice:",_.defaultVoice),f(),f())),e.keyCode=="B".charCodeAt(0)&&(e.preventDefault(),"keyup"==e.type&&(_.defaultReadingSpeed-=.1,f(),f())),e.keyCode=="R".charCodeAt(0)&&(e.preventDefault(),"keyup"==e.type&&(dbg.readability(),dbg.reparsePage())),e.keyCode=="N".charCodeAt(0)&&(e.preventDefault(),"keyup"==e.type&&(_.defaultReadingSpeed+=.1,f(),f())),"Right"==e.keyIdentifier&&(e.preventDefault(),"keyup"==e.type&&O.skipToNextParagraph()),"Left"==e.keyIdentifier&&(e.preventDefault(),"keyup"==e.type&&O.skipToPrevParagraph()))}function c(){a("resume")}function f(e){console.log("processClickEvent",e);var t=(new Date).getTime();if(e){if(e.ctrlKey||e.metaKey)return;e.stopPropagation()}if(window.isSpeaking)console.log("speaker.stop"),O.stop(),a("resume");else{if(this.className){var n=this.className.split(/\s+/),u=n[1].replace(/word/,"");O.crt=Number(u),console.log(t,"processClick start seek ",u,e)}else console.log(t,"processClick resume from ",O.crt,e);O.startCrt=O.crt,console.log("speaker.start 1"),O.speak(),r(e),document.getSelection().removeAllRanges(),window.isSpeaking=!0,console.log("SET1 isSpeaking",window.isSpeaking),a("pause")}}function d(e){if(void 0==window.greek_letters){window.greek_letters={};var t="alpha 3b1|alpha 391|beta 3b2|beta 392|gamma 3b3|gamma 393|delta 3b4|delta 394|epsilon 3b5|epsilon 395|zeta 3b6|zeta 396|eta 3b7|eta 397|theta 3b8|theta 398|iota 3b9|iota 399|kappa 3ba|kappa 39a|lambda 3bb|lambda 39b|mu 3bc|mu 39c|nu 3bd|nu 39d|xi 3be|xi 39e|omicron 3bf|omicron 39f|pi 3c0|pi 3a0|rho 3c1|rho 3a1|sigma 3c3|sigma 3a3|tau 3c4|tau 3a4|upsilon 3c5|upsilon 3a5|phi 3c6|phi 3a6|chi 3c7|chi 3a7|psi 3c8|psi 3a8|omega 3c9|omega 3a9".split("|");for(var n in t){var u=t[n].split(" ");window.greek_letters[u[1]]=u[0]}}return char_code=e.charCodeAt(0).toString(16),window.greek_letters[char_code]}function h(e){return e.replace(/[\u0391-\u03c9]/g,function(e){return" "+d(e)+" "})}function p(e){text2=h(e),console.log(e==text2,"replace form",e,"to",text2),e=text2;var t=L.japaneseSplitStringIntoWords(e).split(/[ \t]+/),n=[];return t.map(function(e){if(e.match(/\,$/))n.push(e.substr(0,e.length-1)),n.push(",");else if(e.match(/\.$/)&&!e.match(/[a-zA-Z0-9-]\.[a-zA-Z0-9-]/))n.push(e.substr(0,e.length-1)),n.push(".");else if(e.match(/http/))n.push(e);else{var t=[];e.match(/-$/)?t.push(e):t=e.split(/-/),t.forEach(function(e){e.length>0&&n.push(e)})}}),n}function g(e){var t=T(e).text();if(!(T(e).parents("noscript").length>0)){var n=p(t).map(function(e){if(""===e)return"";if(e.match(/http/))return" "+e;if(e.match(/^\[[0-9]+\]$/))return" "+e;var t=e.replace(/[^0-9]+/g,"").length,n=e.replace(/[^a-zA-Z]+/g,"").length;if(t>=4&&n>=2||t>=7)return" "+e;var u=_.word_list.length,r={word:e,id:"word"+u};return _.word_list.push(r),"<span class='word "+r.id+"'>"+r.word+"</span>"});e.parentElement&&e.parentElement.localName&&("em"==e.parentElement.localName||"strong"==e.parentElement.localName)&&_.word_list.push({word:" -- ",id:"-filler-"});var u="";return n.map(function(e){u+=e.match(/>[\.,]</)?e:" "+e}),u}}function m(){var e=[],t=C();T("#readInner").length>0?i(T("#readInner")[0],e):t.match("reddit.com$")&&window.location.pathname.match(/comments/)?T(".content .usertext-body p, .content .usertext-body li").each(function(){i(this,e),e.push(" -- ")}):t.match("news.ycombinator.com$")&&T(".comment").length>0?T(".comment").each(function(){i(this,e),e.push(" -- ")}):t.match("plus.google.com$")?T("div[dir='ltr']").each(function(){i(this,e),e.push(" -- ")}):t.match("deeplearn.org$")?T(".article-content").each(function(){i(this,e),e.push(" -- ")}):t.match("twitter.com$")?(T(".tweet-text").each(function(){i(this,e),e.push(" . . . ")}),T("div[lang=en] span").each(function(){i(this,e),e.push(" -- ")})):t.match("slashdot.org$")?T(".article .body, .commentBody").each(function(){i(this,e,function(e){return e.match(/\bsig\b/)}),e.push(" -- ")}):t.match("discordapp.com$")?T(".markup").each(function(){i(this,e),e.push(" -- ")}):t.match("arxiv-sanity.com$")?T(".ts, .tt").each(function(){i(this,e),e.push(" -- ")}):t.match("arxiv-vanity.com$")?T(".content").each(function(){i(this,e,function(e){return e.match(/\b(badge)\b/i)}),e.push(" -- ")}):t.match("openreview.net$")?T(".note_content_value").each(function(){i(this,e),e.push(" -- ")}):t.match("semanticscholar.org$")?(T(".more").trigger("click"),T(".paper-abstract p, .paper-title h1, .abstract").each(function(){i(this,e),e.push(" -- ")})):t.match("arstechnica.com$")?T(".article-content, .comment .body").each(function(){i(this,e,function(e){return e.match(/\b(byline|vote|tools-info|quotetitle|quotecontent)\b/i)}),e.push(" -- ")}):t.match("arxiv.org$")?T(".title, .abstract").each(function(){i(this,e,function(e){return e.match(/MathJax_Preview/i)}),e.push(" -- ")}):t.match("arxiv-vanity.com$")?T(".ltx_page_content").each(function(){i(this,e,function(e){return e.match(/ltx_ERROR/i)}),e.push(" -- ")}):T("body").each(function(){i(this,e)}),window.savTextNodes=e,console.log("textNodes = ",e.length),e.forEach(function(e,n){if("string"==typeof e){var e=I(e);return void _.word_list.push({word:e,id:""})}"news.ycombinator.com"==t&&T(e).text().match("reply")||T(e).replaceWith(g(e,_.word_list))})}function E(e){return void 0===e||null===e.offsetParent}function v(e,t){var n=e;O.startCrt<e&&O.startCrt+50>e&&(console.log("poz from word_list[",O.startCrt,"]=",O.word_list[O.startCrt].word,"to[",e,"]=",O.word_list[e].word),n=O.startCrt,O.startCrt=e);for(var u=n;e>=u;u++)_.word_list[u].read||("page"==ext_or_page?T(".word"+u).animate({opacity:_.fadeOutOpacity},1e3,"ease-in-out"):T(".word"+u).css({boxShadow:"-10px 0px 0px rgb(229, 54, 244), 20px 0px 0px rgb(229, 54, 244)",backgroundColor:"rgb(229, 54, 244)"}),_.word_list[u].read=1);var r=_.word_list[e].id,i=T("."+r)[0],o=P.elementInViewport(i),a=!0,s=C();s.match("plus.google.com$")&&(a=!1),0!=o&&(console.log("elPosition",o,"config.manualScrollDetected",_.manualScrollDetected),_.manualScrollDetected&&o>50&&a?(window.isSpeaking=!1,console.log("SET2 isSpeaking",window.isSpeaking),speechSynthesis.cancel()):E(i)||P.scrollIntoView(i,_.scrollEasing),_.manualScrollDetected=!1)}function y(){O.initialized||(O.init(_.word_list),O.onWord=v,O.onCancel=c,O.onEnd=c)}function b(){var e=L.identifyLanguage(_.word_list);"en"==e&&(_.defaultVoice="Alex",_.defaultReadingSpeed=1.25),"ro"==e&&(_.defaultVoice="Ioana",_.defaultReadingSpeed=1),"jp"==e&&(_.defaultVoice="Otoya",_.defaultReadingSpeed=.8),window.speechSynthesis.onvoiceschanged=function(){y()},y(),setTimeout(function(){y()},500)}function w(e){var t=document.createElement("style");t.type="text/css",t.innerHTML=e,document.body.appendChild(t)}function C(){return window.location.hostname.replace(/^www\./,"")}function A(e){var t=0;T(".word").each(function(){var n=window.getComputedStyle(this,null).getPropertyValue("font-size");parseInt(n,10)<e&&T(this).css("fontSize",e+"px"),t++}),console.log("rescaleWords",e,"count",t,"words",T(".word").length)}function F(){return"chrome-extension:"==window.location.protocol||window.location.pathname.match("/pdfjs/web/viewer.html")?"ext":"page"}function k(){"ext"==ext_or_page?(w(".textLayer { margin-left: -5px; }"),w(".word { padding-top: 1px; }")):(A(_.minimumFontSize),w(".word { line-height:"+_.defaultLineHeight+"; font-weight: 300; font-family: sans-serif; }"))}function x(){var e=C();if(!e.match("plus.google.com$")&&!e.match("feedly.com")){var t,n=document.querySelectorAll("body *");for(t=0;t<n.length;t++)"fixed"===getComputedStyle(n[t]).position&&n[t].parentNode.removeChild(n[t])}}function D(){T(document).unbind("keyup").bind("keyup",l),T(document).unbind("keydown").bind("keydown",l),T(document).unbind("keypress").bind("keypress",l),T(".word").off("click").on("click",f),T("html,body").off("mousewheel").on("mousewheel",function(e){window.isSpeaking&&"page"==ext_or_page&&(_.manualScrollDetected=!0,console.log("cancel speaking"))})}function S(){T(document).bind("DOMNodeInserted",function(e){window.mutation_event_counter++}),window.mutation_event_counter=0,setInterval(function(){window.mutation_event_counter>50&&(console.log("mutation_event_counter =",window.mutation_event_counter),dbg.reparsePage()),window.mutation_event_counter=0},500)}function N(){dbg.parsePageFindWords(),dbg.installEventHandlers(),dbg.applyTextScaling()}function B(){window.audioHasRun?(console.log("parsePageFindWords"),dbg.reparsePage()):(window.isSpeaking=!1,console.log("SET3 isSpeaking",window.isSpeaking),console.log("full init"),window.dbg={$:T,config:_,lang:L,speaker:O,scroll:P,parsePageFindWords:m,processClickEvent:f,applyTextScaling:k,installEventHandlers:D,speechSetup:b,install_speaker_animation:u,speaker_animation:r,readability:$,reparsePage:N,replace_greek_letter_names:h},x(),dbg.reparsePage(),b(),o(),S(),u(),window.audioHasRun=!0)}var T=n(2),_=n(1),L=n(3),O=window.dbg&&dbg.speaker?dbg.speaker:n(7),P=n(6),I=n(4),$=n(5);window.ext_or_page=F(),window.removeLigaturesDiacritics=I,window.crossDomainSendMessage=a;window.main=B,T(B)},function(e,t){e.exports={defaultBackgroundLuminosity:.3,defaultTextSize:"20px",defaultMargin:"20%",defaultLineHeight:"1.75",defaultFontFamily:"Lora, serif",defaultReadingPosition:.07,minimumFontSize:18,defaultBottomGuard:20,minChunkLen:50,maxChunkLen:100,defaultVoice:"Alex",defaultReadingSpeed:1.25,voiceCounter:0,word_list:[],wordListInitialized:!1,scrollTime:500,scrollEasing:"easeInOutCubic",duringAnimatedScroll:!1,manualScrollDetected:!1,fadeOutOpacity:.2}},function(e,t){/*! Zepto 1.1.6 (generated with Zepto Builder) - zepto event ie fx - zeptojs.com/license */var n=function(){function e(e){return null==e?String(e):U[X.call(e)]||"object"}function t(t){return"function"==e(t)}function n(e){return null!=e&&e==e.window}function u(e){return null!=e&&e.nodeType==e.DOCUMENT_NODE}function r(t){return"object"==e(t)}function i(e){return r(e)&&!n(e)&&Object.getPrototypeOf(e)==Object.prototype}function o(e){return"number"==typeof e.length}function a(e){return B.call(e,function(e){return null!=e})}function s(e){return e.length>0?F.fn.concat.apply([],e):e}function l(e){return e.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function c(e){return e in O?O[e]:O[e]=new RegExp("(^|\\s)"+e+"(\\s|$)")}function f(e,t){return"number"!=typeof t||P[l(e)]?t:t+"px"}function d(e){var t,n;return L[e]||(t=_.createElement(e),_.body.appendChild(t),n=getComputedStyle(t,"").getPropertyValue("display"),t.parentNode.removeChild(t),"none"==n&&(n="block"),L[e]=n),L[e]}function h(e){return"children"in e?T.call(e.children):F.map(e.childNodes,function(e){return 1==e.nodeType?e:void 0})}function p(e,t){var n,u=e?e.length:0;for(n=0;u>n;n++)this[n]=e[n];this.length=u,this.selector=t||""}function g(e,t,n){for(A in t)n&&(i(t[A])||K(t[A]))?(i(t[A])&&!i(e[A])&&(e[A]={}),K(t[A])&&!K(e[A])&&(e[A]=[]),g(e[A],t[A],n)):t[A]!==C&&(e[A]=t[A])}function m(e,t){return null==t?F(e):F(e).filter(t)}function E(e,n,u,r){return t(n)?n.call(e,u,r):n}function v(e,t,n){null==n?e.removeAttribute(t):e.setAttribute(t,n)}function y(e,t){var n=e.className||"",u=n&&n.baseVal!==C;return t===C?u?n.baseVal:n:void(u?n.baseVal=t:e.className=t)}function b(e){try{return e?"true"==e||("false"==e?!1:"null"==e?null:+e+""==e?+e:/^[\[\{]/.test(e)?F.parseJSON(e):e):e}catch(t){return e}}function w(e,t){t(e);for(var n=0,u=e.childNodes.length;u>n;n++)w(e.childNodes[n],t)}var C,A,F,k,x,D,S=[],N=S.concat,B=S.filter,T=S.slice,_=window.document,L={},O={},P={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},I=/^\s*<(\w+|!)[^>]*>/,$=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,M=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,z=/^(?:body|html)$/i,R=/([A-Z])/g,j=["val","css","html","text","data","width","height","offset"],V=["after","prepend","before","append"],H=_.createElement("table"),Z=_.createElement("tr"),W={tr:_.createElement("tbody"),tbody:H,thead:H,tfoot:H,td:Z,th:Z,"*":_.createElement("div")},q=/complete|loaded|interactive/,Y=/^[\w-]*$/,U={},X=U.toString,Q={},J=_.createElement("div"),G={tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},K=Array.isArray||function(e){return e instanceof Array};return Q.matches=function(e,t){if(!t||!e||1!==e.nodeType)return!1;var n=e.webkitMatchesSelector||e.mozMatchesSelector||e.oMatchesSelector||e.matchesSelector;if(n)return n.call(e,t);var u,r=e.parentNode,i=!r;return i&&(r=J).appendChild(e),u=~Q.qsa(r,t).indexOf(e),i&&J.removeChild(e),u},x=function(e){return e.replace(/-+(.)?/g,function(e,t){return t?t.toUpperCase():""})},D=function(e){return B.call(e,function(t,n){return e.indexOf(t)==n})},Q.fragment=function(e,t,n){var u,r,o;return $.test(e)&&(u=F(_.createElement(RegExp.$1))),u||(e.replace&&(e=e.replace(M,"<$1></$2>")),t===C&&(t=I.test(e)&&RegExp.$1),t in W||(t="*"),o=W[t],o.innerHTML=""+e,u=F.each(T.call(o.childNodes),function(){o.removeChild(this)})),i(n)&&(r=F(u),F.each(n,function(e,t){j.indexOf(e)>-1?r[e](t):r.attr(e,t)})),u},Q.Z=function(e,t){return new p(e,t)},Q.isZ=function(e){return e instanceof Q.Z},Q.init=function(e,n){var u;if(!e)return Q.Z();if("string"==typeof e)if(e=e.trim(),"<"==e[0]&&I.test(e))u=Q.fragment(e,RegExp.$1,n),e=null;else{if(n!==C)return F(n).find(e);u=Q.qsa(_,e)}else{if(t(e))return F(_).ready(e);if(Q.isZ(e))return e;if(K(e))u=a(e);else if(r(e))u=[e],e=null;else if(I.test(e))u=Q.fragment(e.trim(),RegExp.$1,n),e=null;else{if(n!==C)return F(n).find(e);u=Q.qsa(_,e)}}return Q.Z(u,e)},F=function(e,t){return Q.init(e,t)},F.extend=function(e){var t,n=T.call(arguments,1);return"boolean"==typeof e&&(t=e,e=n.shift()),n.forEach(function(n){g(e,n,t)}),e},Q.qsa=function(e,t){var n,u="#"==t[0],r=!u&&"."==t[0],i=u||r?t.slice(1):t,o=Y.test(i);return e.getElementById&&o&&u?(n=e.getElementById(i))?[n]:[]:1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType?[]:T.call(o&&!u&&e.getElementsByClassName?r?e.getElementsByClassName(i):e.getElementsByTagName(t):e.querySelectorAll(t))},F.contains=_.documentElement.contains?function(e,t){return e!==t&&e.contains(t)}:function(e,t){for(;t&&(t=t.parentNode);)if(t===e)return!0;return!1},F.type=e,F.isFunction=t,F.isWindow=n,F.isArray=K,F.isPlainObject=i,F.isEmptyObject=function(e){var t;for(t in e)return!1;return!0},F.inArray=function(e,t,n){return S.indexOf.call(t,e,n)},F.camelCase=x,F.trim=function(e){return null==e?"":String.prototype.trim.call(e)},F.uuid=0,F.support={},F.expr={},F.noop=function(){},F.map=function(e,t){var n,u,r,i=[];if(o(e))for(u=0;u<e.length;u++)n=t(e[u],u),null!=n&&i.push(n);else for(r in e)n=t(e[r],r),null!=n&&i.push(n);return s(i)},F.each=function(e,t){var n,u;if(o(e)){for(n=0;n<e.length;n++)if(t.call(e[n],n,e[n])===!1)return e}else for(u in e)if(t.call(e[u],u,e[u])===!1)return e;return e},F.grep=function(e,t){return B.call(e,t)},window.JSON&&(F.parseJSON=JSON.parse),F.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){U["[object "+t+"]"]=t.toLowerCase()}),F.fn={constructor:Q.Z,length:0,forEach:S.forEach,reduce:S.reduce,push:S.push,sort:S.sort,splice:S.splice,indexOf:S.indexOf,concat:function(){var e,t,n=[];for(e=0;e<arguments.length;e++)t=arguments[e],n[e]=Q.isZ(t)?t.toArray():t;return N.apply(Q.isZ(this)?this.toArray():this,n)},map:function(e){return F(F.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return F(T.apply(this,arguments))},ready:function(e){return q.test(_.readyState)&&_.body?e(F):_.addEventListener("DOMContentLoaded",function(){e(F)},!1),this},get:function(e){return e===C?T.call(this):this[e>=0?e:e+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each(function(){null!=this.parentNode&&this.parentNode.removeChild(this)})},each:function(e){return S.every.call(this,function(t,n){return e.call(t,n,t)!==!1}),this},filter:function(e){return t(e)?this.not(this.not(e)):F(B.call(this,function(t){return Q.matches(t,e)}))},add:function(e,t){return F(D(this.concat(F(e,t))))},is:function(e){return this.length>0&&Q.matches(this[0],e)},not:function(e){var n=[];if(t(e)&&e.call!==C)this.each(function(t){e.call(this,t)||n.push(this)});else{var u="string"==typeof e?this.filter(e):o(e)&&t(e.item)?T.call(e):F(e);this.forEach(function(e){u.indexOf(e)<0&&n.push(e)})}return F(n)},has:function(e){return this.filter(function(){return r(e)?F.contains(this,e):F(this).find(e).size()})},eq:function(e){return-1===e?this.slice(e):this.slice(e,+e+1)},first:function(){var e=this[0];return e&&!r(e)?e:F(e)},last:function(){var e=this[this.length-1];return e&&!r(e)?e:F(e)},find:function(e){var t,n=this;return t=e?"object"==typeof e?F(e).filter(function(){var e=this;return S.some.call(n,function(t){return F.contains(t,e)})}):1==this.length?F(Q.qsa(this[0],e)):this.map(function(){return Q.qsa(this,e)}):F()},closest:function(e,t){var n=this[0],r=!1;for("object"==typeof e&&(r=F(e));n&&!(r?r.indexOf(n)>=0:Q.matches(n,e));)n=n!==t&&!u(n)&&n.parentNode;return F(n)},parents:function(e){for(var t=[],n=this;n.length>0;)n=F.map(n,function(e){return(e=e.parentNode)&&!u(e)&&t.indexOf(e)<0?(t.push(e),e):void 0});return m(t,e)},parent:function(e){return m(D(this.pluck("parentNode")),e)},children:function(e){return m(this.map(function(){return h(this)}),e)},contents:function(){return this.map(function(){return this.contentDocument||T.call(this.childNodes)})},siblings:function(e){return m(this.map(function(e,t){return B.call(h(t.parentNode),function(e){return e!==t})}),e)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(e){return F.map(this,function(t){return t[e]})},show:function(){return this.each(function(){"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=d(this.nodeName))})},replaceWith:function(e){return this.before(e).remove()},wrap:function(e){var n=t(e);if(this[0]&&!n)var u=F(e).get(0),r=u.parentNode||this.length>1;return this.each(function(t){F(this).wrapAll(n?e.call(this,t):r?u.cloneNode(!0):u)})},wrapAll:function(e){if(this[0]){F(this[0]).before(e=F(e));for(var t;(t=e.children()).length;)e=t.first();F(e).append(this)}return this},wrapInner:function(e){var n=t(e);return this.each(function(t){var u=F(this),r=u.contents(),i=n?e.call(this,t):e;r.length?r.wrapAll(i):u.append(i)})},unwrap:function(){return this.parent().each(function(){F(this).replaceWith(F(this).children())}),this},clone:function(){return this.map(function(){return this.cloneNode(!0)})},hide:function(){return this.css("display","none")},toggle:function(e){return this.each(function(){var t=F(this);(e===C?"none"==t.css("display"):e)?t.show():t.hide()})},prev:function(e){return F(this.pluck("previousElementSibling")).filter(e||"*")},next:function(e){return F(this.pluck("nextElementSibling")).filter(e||"*")},html:function(e){return 0 in arguments?this.each(function(t){var n=this.innerHTML;F(this).empty().append(E(this,e,t,n))}):0 in this?this[0].innerHTML:null},text:function(e){return 0 in arguments?this.each(function(t){var n=E(this,e,t,this.textContent);this.textContent=null==n?"":""+n}):0 in this?this.pluck("textContent").join(""):null},attr:function(e,t){var n;return"string"!=typeof e||1 in arguments?this.each(function(n){if(1===this.nodeType)if(r(e))for(A in e)v(this,A,e[A]);else v(this,e,E(this,t,n,this.getAttribute(e)))}):this.length&&1===this[0].nodeType?!(n=this[0].getAttribute(e))&&e in this[0]?this[0][e]:n:C},removeAttr:function(e){return this.each(function(){1===this.nodeType&&e.split(" ").forEach(function(e){v(this,e)},this)})},prop:function(e,t){return e=G[e]||e,1 in arguments?this.each(function(n){this[e]=E(this,t,n,this[e])}):this[0]&&this[0][e]},data:function(e,t){var n="data-"+e.replace(R,"-$1").toLowerCase(),u=1 in arguments?this.attr(n,t):this.attr(n);return null!==u?b(u):C},val:function(e){return 0 in arguments?this.each(function(t){this.value=E(this,e,t,this.value)}):this[0]&&(this[0].multiple?F(this[0]).find("option").filter(function(){return this.selected}).pluck("value"):this[0].value)},offset:function(e){if(e)return this.each(function(t){var n=F(this),u=E(this,e,t,n.offset()),r=n.offsetParent().offset(),i={top:u.top-r.top,left:u.left-r.left};"static"==n.css("position")&&(i.position="relative"),n.css(i)});if(!this.length)return null;if(!F.contains(_.documentElement,this[0]))return{top:0,left:0};var t=this[0].getBoundingClientRect();return{left:t.left+window.pageXOffset,top:t.top+window.pageYOffset,width:Math.round(t.width),height:Math.round(t.height)}},css:function(t,n){if(arguments.length<2){var u,r=this[0];if(!r)return;if(u=getComputedStyle(r,""),"string"==typeof t)return r.style[x(t)]||u.getPropertyValue(t);if(K(t)){var i={};return F.each(t,function(e,t){i[t]=r.style[x(t)]||u.getPropertyValue(t)}),i}}var o="";if("string"==e(t))n||0===n?o=l(t)+":"+f(t,n):this.each(function(){this.style.removeProperty(l(t))});else for(A in t)t[A]||0===t[A]?o+=l(A)+":"+f(A,t[A])+";":this.each(function(){this.style.removeProperty(l(A))});return this.each(function(){this.style.cssText+=";"+o})},index:function(e){return e?this.indexOf(F(e)[0]):this.parent().children().indexOf(this[0])},hasClass:function(e){return e?S.some.call(this,function(e){return this.test(y(e))},c(e)):!1},addClass:function(e){return e?this.each(function(t){if("className"in this){k=[];var n=y(this),u=E(this,e,t,n);u.split(/\s+/g).forEach(function(e){F(this).hasClass(e)||k.push(e)},this),k.length&&y(this,n+(n?" ":"")+k.join(" "))}}):this},removeClass:function(e){return this.each(function(t){if("className"in this){if(e===C)return y(this,"");k=y(this),E(this,e,t,k).split(/\s+/g).forEach(function(e){k=k.replace(c(e)," ")}),y(this,k.trim())}})},toggleClass:function(e,t){return e?this.each(function(n){var u=F(this),r=E(this,e,n,y(this));r.split(/\s+/g).forEach(function(e){(t===C?!u.hasClass(e):t)?u.addClass(e):u.removeClass(e)})}):this},scrollTop:function(e){if(this.length){var t="scrollTop"in this[0];return e===C?t?this[0].scrollTop:this[0].pageYOffset:this.each(t?function(){this.scrollTop=e}:function(){this.scrollTo(this.scrollX,e)})}},scrollLeft:function(e){if(this.length){var t="scrollLeft"in this[0];return e===C?t?this[0].scrollLeft:this[0].pageXOffset:this.each(t?function(){this.scrollLeft=e}:function(){this.scrollTo(e,this.scrollY)})}},position:function(){if(this.length){var e=this[0],t=this.offsetParent(),n=this.offset(),u=z.test(t[0].nodeName)?{top:0,left:0}:t.offset();return n.top-=parseFloat(F(e).css("margin-top"))||0,n.left-=parseFloat(F(e).css("margin-left"))||0,u.top+=parseFloat(F(t[0]).css("border-top-width"))||0,u.left+=parseFloat(F(t[0]).css("border-left-width"))||0,{top:n.top-u.top,left:n.left-u.left}}},offsetParent:function(){return this.map(function(){for(var e=this.offsetParent||_.body;e&&!z.test(e.nodeName)&&"static"==F(e).css("position");)e=e.offsetParent;return e})}},F.fn.detach=F.fn.remove,["width","height"].forEach(function(e){var t=e.replace(/./,function(e){return e[0].toUpperCase()});F.fn[e]=function(r){var i,o=this[0];return r===C?n(o)?o["inner"+t]:u(o)?o.documentElement["scroll"+t]:(i=this.offset())&&i[e]:this.each(function(t){o=F(this),o.css(e,E(this,r,t,o[e]()))})}}),V.forEach(function(t,n){var u=n%2;F.fn[t]=function(){var t,r,i=F.map(arguments,function(n){return t=e(n),"object"==t||"array"==t||null==n?n:Q.fragment(n)}),o=this.length>1;return i.length<1?this:this.each(function(e,t){r=u?t:t.parentNode,t=0==n?t.nextSibling:1==n?t.firstChild:2==n?t:null;var a=F.contains(_.documentElement,r);i.forEach(function(e){if(o)e=e.cloneNode(!0);else if(!r)return F(e).remove();r.insertBefore(e,t),a&&w(e,function(e){null==e.nodeName||"SCRIPT"!==e.nodeName.toUpperCase()||e.type&&"text/javascript"!==e.type||e.src||window.eval.call(window,e.innerHTML)})})})},F.fn[u?t+"To":"insert"+(n?"Before":"After")]=function(e){return F(e)[t](this),this}}),Q.Z.prototype=p.prototype=F.fn,Q.uniq=D,Q.deserializeValue=b,F.zepto=Q,F}();window.Zepto=n,void 0===window.$&&(window.$=n),function(e){function t(e){return e._zid||(e._zid=d++)}function n(e,n,i,o){if(n=u(n),n.ns)var a=r(n.ns);return(m[t(e)]||[]).filter(function(e){return e&&(!n.e||e.e==n.e)&&(!n.ns||a.test(e.ns))&&(!i||t(e.fn)===t(i))&&(!o||e.sel==o)})}function u(e){var t=(""+e).split(".");return{e:t[0],ns:t.slice(1).sort().join(" ")}}function r(e){return new RegExp("(?:^| )"+e.replace(" "," .* ?")+"(?: |$)")}function i(e,t){return e.del&&!v&&e.e in y||!!t}function o(e){return b[e]||v&&y[e]||e}function a(n,r,a,s,c,d,h){var p=t(n),g=m[p]||(m[p]=[]);r.split(/\s/).forEach(function(t){if("ready"==t)return e(document).ready(a);var r=u(t);r.fn=a,r.sel=c,r.e in b&&(a=function(t){var n=t.relatedTarget;return!n||n!==this&&!e.contains(this,n)?r.fn.apply(this,arguments):void 0}),r.del=d;var p=d||a;r.proxy=function(e){if(e=l(e),!e.isImmediatePropagationStopped()){e.data=s;var t=p.apply(n,e._args==f?[e]:[e].concat(e._args));return t===!1&&(e.preventDefault(),e.stopPropagation()),t}},r.i=g.length,g.push(r),"addEventListener"in n&&n.addEventListener(o(r.e),r.proxy,i(r,h))})}function s(e,u,r,a,s){var l=t(e);(u||"").split(/\s/).forEach(function(t){n(e,t,r,a).forEach(function(t){delete m[l][t.i],"removeEventListener"in e&&e.removeEventListener(o(t.e),t.proxy,i(t,s))})})}function l(t,n){return(n||!t.isDefaultPrevented)&&(n||(n=t),e.each(F,function(e,u){var r=n[e];t[e]=function(){return this[u]=w,r&&r.apply(n,arguments)},t[u]=C}),(n.defaultPrevented!==f?n.defaultPrevented:"returnValue"in n?n.returnValue===!1:n.getPreventDefault&&n.getPreventDefault())&&(t.isDefaultPrevented=w)),t}function c(e){var t,n={originalEvent:e};for(t in e)A.test(t)||e[t]===f||(n[t]=e[t]);return l(n,e)}var f,d=1,h=Array.prototype.slice,p=e.isFunction,g=function(e){return"string"==typeof e},m={},E={},v="onfocusin"in window,y={focus:"focusin",blur:"focusout"},b={mouseenter:"mouseover",mouseleave:"mouseout"};E.click=E.mousedown=E.mouseup=E.mousemove="MouseEvents",e.event={add:a,remove:s},e.proxy=function(n,u){var r=2 in arguments&&h.call(arguments,2);if(p(n)){var i=function(){return n.apply(u,r?r.concat(h.call(arguments)):arguments)};return i._zid=t(n),i}if(g(u))return r?(r.unshift(n[u],n),e.proxy.apply(null,r)):e.proxy(n[u],n);throw new TypeError("expected function")},e.fn.bind=function(e,t,n){return this.on(e,t,n)},e.fn.unbind=function(e,t){return this.off(e,t)},e.fn.one=function(e,t,n,u){return this.on(e,t,n,u,1)};var w=function(){return!0},C=function(){return!1},A=/^([A-Z]|returnValue$|layer[XY]$)/,F={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};e.fn.delegate=function(e,t,n){return this.on(t,e,n)},e.fn.undelegate=function(e,t,n){return this.off(t,e,n)},e.fn.live=function(t,n){return e(document.body).delegate(this.selector,t,n),this},e.fn.die=function(t,n){return e(document.body).undelegate(this.selector,t,n),this},e.fn.on=function(t,n,u,r,i){var o,l,d=this;return t&&!g(t)?(e.each(t,function(e,t){d.on(e,n,u,t,i)}),d):(g(n)||p(r)||r===!1||(r=u,u=n,n=f),(r===f||u===!1)&&(r=u,u=f),r===!1&&(r=C),d.each(function(f,d){i&&(o=function(e){return s(d,e.type,r),r.apply(this,arguments)}),n&&(l=function(t){var u,i=e(t.target).closest(n,d).get(0);return i&&i!==d?(u=e.extend(c(t),{currentTarget:i,liveFired:d}),(o||r).apply(i,[u].concat(h.call(arguments,1)))):void 0}),a(d,t,r,u,n,l||o)}))},e.fn.off=function(t,n,u){var r=this;return t&&!g(t)?(e.each(t,function(e,t){r.off(e,n,t)}),r):(g(n)||p(u)||u===!1||(u=n,n=f),u===!1&&(u=C),r.each(function(){s(this,t,u,n)}))},e.fn.trigger=function(t,n){return t=g(t)||e.isPlainObject(t)?e.Event(t):l(t),t._args=n,this.each(function(){t.type in y&&"function"==typeof this[t.type]?this[t.type]():"dispatchEvent"in this?this.dispatchEvent(t):e(this).triggerHandler(t,n)})},e.fn.triggerHandler=function(t,u){var r,i;return this.each(function(o,a){r=c(g(t)?e.Event(t):t),r._args=u,r.target=a,e.each(n(a,t.type||t),function(e,t){return i=t.proxy(r),r.isImmediatePropagationStopped()?!1:void 0})}),i},"focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function(t){e.fn[t]=function(e){return 0 in arguments?this.bind(t,e):this.trigger(t)}}),e.Event=function(e,t){g(e)||(t=e,e=t.type);var n=document.createEvent(E[e]||"Events"),u=!0;if(t)for(var r in t)"bubbles"==r?u=!!t[r]:n[r]=t[r];return n.initEvent(e,u,!0),l(n)}}(n),function(e,t){function n(e){return e.replace(/([a-z])([A-Z])/,"$1-$2").toLowerCase()}function u(e){return r?r+e:e.toLowerCase()}var r,i,o,a,s,l,c,f,d,h,p="",g={Webkit:"webkit",Moz:"",O:"o"},m=document.createElement("div"),E=/^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i,v={};e.each(g,function(e,n){return m.style[e+"TransitionProperty"]!==t?(p="-"+e.toLowerCase()+"-",r=n,!1):void 0}),i=p+"transform",v[o=p+"transition-property"]=v[a=p+"transition-duration"]=v[l=p+"transition-delay"]=v[s=p+"transition-timing-function"]=v[c=p+"animation-name"]=v[f=p+"animation-duration"]=v[h=p+"animation-delay"]=v[d=p+"animation-timing-function"]="",e.fx={off:r===t&&m.style.transitionProperty===t,speeds:{_default:400,fast:200,slow:600},cssPrefix:p,transitionEnd:u("TransitionEnd"),animationEnd:u("AnimationEnd")},e.fn.animate=function(n,u,r,i,o){return e.isFunction(u)&&(i=u,r=t,u=t),e.isFunction(r)&&(i=r,r=t),e.isPlainObject(u)&&(r=u.easing,i=u.complete,o=u.delay,u=u.duration),u&&(u=("number"==typeof u?u:e.fx.speeds[u]||e.fx.speeds._default)/1e3),o&&(o=parseFloat(o)/1e3),this.anim(n,u,r,i,o)},e.fn.anim=function(u,r,p,g,m){var y,b,w,C={},A="",F=this,k=e.fx.transitionEnd,x=!1;if(r===t&&(r=e.fx.speeds._default/1e3),m===t&&(m=0),e.fx.off&&(r=0),"string"==typeof u)C[c]=u,C[f]=r+"s",C[h]=m+"s",C[d]=p||"linear",k=e.fx.animationEnd;else{b=[];for(y in u)E.test(y)?A+=y+"("+u[y]+") ":(C[y]=u[y],b.push(n(y)));A&&(C[i]=A,b.push(i)),r>0&&"object"==typeof u&&(C[o]=b.join(", "),C[a]=r+"s",C[l]=m+"s",C[s]=p||"linear")}return w=function(t){if("undefined"!=typeof t){if(t.target!==t.currentTarget)return;e(t.target).unbind(k,w)}else e(this).unbind(k,w);x=!0,e(this).css(v),g&&g.call(this)},r>0&&(this.bind(k,w),setTimeout(function(){x||w.call(F)},1e3*(r+m)+25)),this.size()&&this.get(0).clientLeft,this.css(C),0>=r&&setTimeout(function(){F.each(function(){w.call(this)})},0),this},m=null}(n),function(){try{getComputedStyle(void 0)}catch(e){var t=getComputedStyle;window.getComputedStyle=function(e){try{return t(e)}catch(n){return null}}}}(),e.exports=n},function(e,t){function n(){var e="the,and,to,of,in,are,a,is,be,have,all,on,has,been,as,their,can,more,for,or",t="de,și,în,a,un,pe,la,se,este,cu,că,ai,fi,mai,din,sunt,să,prin,sau,nu",n={};return e.split(",").forEach(function(e){n[e]="en"}),t.split(",").forEach(function(e){n[e]="ro"}),n}function u(e){var t=n(),u={en:0,ro:0},i=0,o=0;return e.slice(0,1e3).forEach(function(e){var n=e.word.toLowerCase(),a=r(n);"kanji"!=a&&"katakana"!=a&&"hiragana"!=a||o++,void 0!=t[n]&&(u[t[n]]++,i++)}),o>5&&o>i?"jp":i>5?u.en>u.ro?"en":"ro":"en"}function r(e){var t=e.charCodeAt(0);return t>=48&&57>=t||t>=65&&90>=t||t>=97&&122>=t||45==t||95==t?"letter":12289==t||12290==t?"separator":1e3>t?"letter":t>=12353&&12438>=t?"hiragana":t>=12449&&12542>=t?"katakana":t>=11910&&40900>=t?"kanji":"symbol"}function i(e){if(""==e)return"";for(var t=r(e[0]),n=e[0],u=1;u<e.length;u++){var i=r(e[u]);"separator"==i?(n+=e[u],n+=" "):"hiragana"!=t&&"katakana"!=t||"kanji"!=i?"hiragana"==t&&"katakana"==i||"katakana"==t&&"hiragana"==i?(n+=" ",n+=e[u]):"kanji"==t&&"katakana"==i?(n+=" ",n+=e[u]):n+=e[u]:(n+=" ",n+=e[u]),t=i}return n.replace(/ +/," ")}e.exports={identifyLanguage:u,japaneseSplitStringIntoWords:i}},function(e,t){function n(e){u||(u=r);for(var t=0;t<u.length;t++)e=e.replace(u[t].letters,u[t].base);return e}var u,r=[{base:"A",letters:/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},{base:"AA",letters:/[\uA732]/g},{base:"AE",letters:/[\u00C6\u01FC\u01E2]/g},{base:"AO",letters:/[\uA734]/g},{base:"AU",letters:/[\uA736]/g},{base:"AV",letters:/[\uA738\uA73A]/g},{base:"AY",letters:/[\uA73C]/g},{base:"B",letters:/[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g},{base:"C",letters:/[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]/g},{base:"D",letters:/[\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779]/g},{base:"DZ",letters:/[\u01F1\u01C4]/g},{base:"Dz",letters:/[\u01F2\u01C5]/g},{base:"E",letters:/[\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E]/g},{base:"F",letters:/[\u0046\u24BB\uFF26\u1E1E\u0191\uA77B]/g},{base:"G",letters:/[\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E]/g},{base:"H",letters:/[\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D]/g},{base:"I",letters:/[\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197]/g},{base:"J",letters:/[\u004A\u24BF\uFF2A\u0134\u0248]/g},{base:"K",letters:/[\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2]/g},{base:"L",letters:/[\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780]/g},{base:"LJ",letters:/[\u01C7]/g},{base:"Lj",letters:/[\u01C8]/g},{base:"M",letters:/[\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C]/g},{base:"N",letters:/[\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4]/g},{base:"NJ",letters:/[\u01CA]/g},{base:"Nj",letters:/[\u01CB]/g},{base:"O",letters:/[\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C]/g},{base:"OI",letters:/[\u01A2]/g},{base:"OO",letters:/[\uA74E]/g},{base:"OU",letters:/[\u0222]/g},{base:"P",letters:/[\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754]/g},{base:"Q",letters:/[\u0051\u24C6\uFF31\uA756\uA758\u024A]/g},{base:"R",letters:/[\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782]/g},{base:"S",letters:/[\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784]/g},{base:"T",letters:/[\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786]/g},{base:"TZ",letters:/[\uA728]/g},{base:"U",letters:/[\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244]/g},{base:"V",letters:/[\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245]/g},{base:"VY",letters:/[\uA760]/g},{base:"W",letters:/[\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72]/g},{base:"X",letters:/[\u0058\u24CD\uFF38\u1E8A\u1E8C]/g},{base:"Y",letters:/[\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE]/g},{base:"Z",letters:/[\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762]/g},{base:"a",letters:/[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250]/g},{base:"aa",letters:/[\uA733]/g},{base:"ae",letters:/[\u00E6\u01FD\u01E3]/g},{base:"ao",letters:/[\uA735]/g},{base:"au",letters:/[\uA737]/g},{base:"av",letters:/[\uA739\uA73B]/g},{base:"ay",letters:/[\uA73D]/g},{base:"b",letters:/[\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253]/g},{base:"c",letters:/[\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184]/g},{base:"d",letters:/[\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A]/g},{base:"dz",letters:/[\u01F3\u01C6]/g},{base:"e",letters:/[\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD]/g},{base:"f",letters:/[\u0066\u24D5\uFF46\u1E1F\u0192\uA77C]/g},{base:"g",letters:/[\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F]/g},{base:"h",letters:/[\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265]/g},{base:"hv",letters:/[\u0195]/g},{base:"i",letters:/[\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131]/g},{base:"j",letters:/[\u006A\u24D9\uFF4A\u0135\u01F0\u0249]/g},{base:"k",letters:/[\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3]/g},{base:"l",letters:/[\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747]/g},{base:"lj",letters:/[\u01C9]/g},{base:"m",letters:/[\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F]/g},{base:"n",letters:/[\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5]/g},{base:"nj",letters:/[\u01CC]/g},{base:"o",letters:/[\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275]/g},{base:"oi",letters:/[\u01A3]/g},{base:"ou",letters:/[\u0223]/g},{base:"oo",letters:/[\uA74F]/g},{base:"p",letters:/[\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755]/g},{base:"q",letters:/[\u0071\u24E0\uFF51\u024B\uA757\uA759]/g},{base:"r",letters:/[\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783]/g},{base:"s",letters:/[\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B]/g},{base:"t",letters:/[\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787]/g},{base:"tz",letters:/[\uA729]/g},{base:"u",letters:/[\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289]/g},{base:"v",letters:/[\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C]/g},{base:"vy",letters:/[\uA761]/g},{base:"w",letters:/[\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73]/g},{base:"x",letters:/[\u0078\u24E7\uFF58\u1E8B\u1E8D]/g},{base:"y",letters:/[\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF]/g},{base:"z",letters:/[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]/g}];e.exports=n},function(e,t,n){function u(){if(p("#readOverlay").length>0)return void console.log("Already installed. Aborting.");var e=document.getElementsByTagName("script");for(k=0;k<e.length;k++)null==e[k].src||e[k].src.match(/readability|[Cc]lippability/)||e[k].parentNode.removeChild(e[k]);p("script").each(function(){this.src.match(/readability|[Cc]lippability|jquery\.min\.js$/)||p(this).remove()});var t=document.createElement("div"),n=document.createElement("div");t.id="readOverlay",n.id="readInner",document.body.className=g,t.className=g,n.className=E+" "+m,n.appendChild(i()),t.appendChild(n),null==document.body&&(body=document.createElement("body"),document.body=body),document.body.innerHTML="",document.body.insertBefore(t,document.body.firstChild);var u=document.body.firstChild;return p("body").css({marginLeft:"20%",marginRight:"20%"}),u.innerHTML}function r(e,t){t||(t=document.getElementsByTagName("body")[0]);for(var n=[],u=new RegExp("\\b"+e+"\\b"),r=t.getElementsByTagName("*"),i=0,o=r.length;o>i;i++)u.test(r[i].className)&&n.push(r[i]);return n}function i(){var e=document.getElementsByTagName("p"),t=null,n=document.createElement("DIV"),u=document.createElement("H1"),i=document.createElement("DIV"),p=new RegExp("<br/?>[ \r\ns]*<br/?>","g");document.body.innerHTML=document.body.innerHTML.replace(p,"</p><p>").replace(/<\/?font[^>]*>/g,""),u.innerHTML=document.title,n.appendChild(u);for(var g=0;g<e.length;g++)parentNode=e[g].parentNode,"undefined"==typeof parentNode.readability&&(parentNode.readability={contentScore:0},parentNode.className.match(/(comment|meta|footer|footnote)/)?parentNode.readability.contentScore-=50:parentNode.className.match(/((^|\\s)(post|hentry|entry[-]?(content|text|body)?|article[-]?(content|text|body)?)(\\s|$))/)&&(parentNode.readability.contentScore+=25),parentNode.id.match(/(comment|meta|footer|footnote)/)?parentNode.readability.contentScore-=50:parentNode.id.match(/^(post|hentry|entry[-]?(content|text|body)?|article[-]?(content|text|body)?)$/)&&(parentNode.readability.contentScore+=25)),a(e[g]).length>10&&parentNode.readability.contentScore++,parentNode.readability.contentScore+=s(e[g]);for(nodeIndex=0;node=document.getElementsByTagName("*")[nodeIndex];nodeIndex++)"undefined"!=typeof node.readability&&(null==t||node.readability.contentScore>t.readability.contentScore)&&(t=node);null==t&&(t=document.createElement("div"),t.innerHTML='Sorry, clippable was unable to parse this page for content. If you feel like it should have been able to, please <a href="http://brettterpstra.com/contact">let us know.</a>');for(var m=0;m<document.styleSheets.length;m++)null!=document.styleSheets[m].href&&-1==document.styleSheets[m].href.lastIndexOf("readability")&&(document.styleSheets[m].disabled=!0);for(var E=r("syntaxhighlighter"),v=0;v<E.length;v++){var y=r("toolbar",E[v]);if(y.length>0)for(var b=0;b<y.length;b++)y[b].parentNode.removeChild(y[b]);var w=r("number",E[v]);if(w.length>0)for(var C=0;C<w.length;C++)w[C].parentNode.removeChild(w[C])}for(var A=r("dp-highlighter"),F=0;F<A.length;F++)A[F].parentNode.removeChild(A[F]);var k=r("standardLighter");for(F=0;F<k.length;F++)k[F].parentNode.removeChild(k[F]);for(var x=document.getElementsByTagName("style"),D=0;D<x.length;D++)"Microsoft Internet Explorer"!=navigator.appName&&(x[D].textContent="");return t=d(t),l(t),t=c(t),t=f(t),t=h(t,"form"),t=h(t,"table",8),t=h(t,"h1"),t=h(t,"iframe"),i.id="readFooter",i.innerHTML="END",n.appendChild(t),document.onkeyup=o,n}function o(e){var t=null;t="Microsoft Internet Explorer"==navigator.appName?event.keyCode:window.event?event.keyCode:e.keyCode;var n,u,r;switch(t){case 27:document.location.reload(!0);break;case 37:n="#222",u="#F3EFCE",r="#A19F89";break;case 39:n="#fff",u="#333",r="#276F78";break;case 46:n="#eee",u="#333",r="#blue"}body=document.getElementById("readOverlay"),body.style.backgroundColor=n,body.style.color=u;for(var i=body.getElementsByTagName("a"),o=0;o<i.length;o++)i[o].style.color=r}function a(e){return"Microsoft Internet Explorer"==navigator.appName?e.innerText:e.textContent}function s(e,t){return t=t||",",a(e).split(t).length}function l(e){e=e||document;var t=e.firstChild;if(e)for("function"==typeof e.removeAttribute&&e.removeAttribute("style");null!=t;)1==t.nodeType&&(t.removeAttribute("style"),l(t)),t=t.nextSibling}function c(e){for(var t=e.getElementsByTagName("div"),n=t.length,u=n-1;u>=0;u--){var r=t[u].getElementsByTagName("p").length,i=t[u].getElementsByTagName("img").length,o=t[u].getElementsByTagName("li").length,a=t[u].getElementsByTagName("a").length,l=t[u].getElementsByTagName("embed").length,c=t[u].getElementsByTagName("object").length,f=t[u].getElementsByTagName("pre").length,d=t[u].getElementsByTagName("code").length,h=t[u].id,p=t[u].className,g=null==t[u].innerHTML.match("<!-- sphereit")?0:1;s(t[u])<10&&(i>r||o>r||a>r||0==r||null!=h.match("comment")||null!=p.match("comment")||null!=h.match("share")||null!=p.match("share"))&&0==f&&0==d&&0==l&&0==c&&0==g&&0==!r&&1==i&&t[u].parentNode.removeChild(t[u]);for(var m=["comment","share","footer","^ad"],E=0;E<m.length;E++)regex=new RegExp(m[E]),null==h.match(regex)&&null==p.match(regex)||(console.log("matched "+m[E]),t[u].parentNode.removeChild(t[u]))}return e}function f(e){return e.innerHTML=e.innerHTML.replace(/(<br\s*\/?>(\s|&nbsp;?)*){1,}/g,"<br />"),e}function d(e){return e.innerHTML=e.innerHTML.replace(/<\/?\s?span(?:[^>]+)?>/g,""),e}function h(e,t,n){var u,r;if("table"==t)for(u=e.getElementsByTagName(t),n=n||1e6,r=0;r<u.length;r++)cells=u[r].getElementsByTagName("td").length,cells<n&&u[r].parentNode.removeChild(u[r]);else for(u=e.getElementsByTagName(t),n=n||1e6,r=0;r<u.length;r++)s(u[r]," ")<n&&"pre"!=u[r].tagName&&u[r].parentNode.removeChild(u[r]);return e}var p=n(2),g="style-ebook",m="size-medium",E="margin-wide";e.exports=u},function(e,t,n){function u(e){function t(e,t,n){var u=t-e;0>u&&(u=0);var r=u>n?u:n;return r}if(!e||!e.offsetTop)return void console.log("elementInViewport error",e);for(var n=e.offsetTop,u=e.offsetLeft,r=(e.offsetWidth,e.offsetHeight+f.defaultBottomGuard);e.offsetParent;)e=e.offsetParent,n+=e.offsetTop,u+=e.offsetLeft;var i=0;return i=t(n,window.pageYOffset-100,i),i=t(window.pageYOffset+window.innerHeight,n+r,i)}function r(e){var t=0,n=0;do t+=e.offsetTop||0,n+=e.offsetLeft||0,e=e.offsetParent;while(e);return{top:t,left:n}}function i(e,t,n,u){function r(e,t){return t>e?e:t}function i(l){setTimeout(function(){var l=Date.now(),c=r(1,(l-o)/t),d=n(c);a.scrollTop=d*(e-s)+s,1>c&&!f.manualScrollDetected?requestAnimationFrame(i):(f.manualScrollDetected=!1,u&&u())},15)}var o=Date.now(),a=document.documentElement.scrollTop?document.documentElement:document.body,s=a.scrollTop;return s===e?void u():(f.manualScrollDetected=!1,void requestAnimationFrame(i))}function o(e,t){if(void 0!=e&&!f.duringAnimatedScroll){f.duringAnimatedScroll=!0,setTimeout(function(){f.duringAnimatedScroll=!1},f.scrollTime+50);var n=r(e),u=n.top-window.innerHeight*f.defaultReadingPosition;i(u,f.scrollTime,d[t||"easeInOutCubic"])}}function a(e,t){if(void 0!=e){var n=r(e);i(n.top,f.scrollTime,d[t||"easeInOutCubic"])}}function s(){var e=[];f.word_list.forEach(function(t){""!=t.id&&e.push(t)});for(var t=0,n=e.length-1,u=window.pageYOffset;n>t+1;){var i=Math.floor((t+n)/2),o=c("."+e[i].id)[0];if(void 0!=o){var a=r(o);a.top>u?n=i:t=i}else console.log("el undefined")}return e[i].id}function l(e){var t=s();e(),setTimeout(function(){a(c("."+t)[0])},50)}var c=n(2),f=n(1),d={linear:function(e){return e},easeInQuad:function(e){return e*e},easeOutQuad:function(e){return e*(2-e)},easeInOutQuad:function(e){return.5>e?2*e*e:-1+(4-2*e)*e},easeInCubic:function(e){return e*e*e},easeOutCubic:function(e){return--e*e*e+1},easeInOutCubic:function(e){return.5>e?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},easeInQuart:function(e){return e*e*e*e},easeOutQuart:function(e){return 1- --e*e*e*e},easeInOutQuart:function(e){return.5>e?8*e*e*e*e:1-8*--e*e*e*e},easeInQuint:function(e){return e*e*e*e*e},easeOutQuint:function(e){return 1+--e*e*e*e*e},easeInOutQuint:function(e){return.5>e?16*e*e*e*e*e:1+16*--e*e*e*e*e}};e.exports={scrollIntoView:o,scrollTo:i,scrollIntoViewAtTop:a,setLineSpacing:l,elementInViewport:u}},function(e,t,n){function u(e){if(e==document)return!0;if(!e)return!1;var t=window.getComputedStyle(e);if(t){if("none"==t.display)return!1;if("hidden"==t.visibility)return!1}return u(e.parentNode)}function r(e,t,n){var u=e.length,r=t.length;if(1>u||1>r||r>u)return-1;for(var i=n;u-r+1>i;i++){for(var o=!0,a=0;r>a;a++){if(!e[i+a]){o=!1;break}var s=e[i+a].word;if(" -- "==s&&(s="--"),s!=t[a]){o=!1;break}}if(o)return i}return-1}function i(e){speechSynthesis.cancel();var t=new SpeechSynthesisUtterance;window.speechUtterance=t;var n=window.speechSynthesis.getVoices();if(0==n.length)return void console.log("Speech error: cannot load voices list.");for(var u=-1,r=0;r<n.length;r++)if(n[r].name==e.voice){u=r;break}return-1==u?void console.log("Voice not found:",e.voice):(t.voice=n[u],t.voiceURI="native",t.volume=1,t.rate=e.speed||o.defaultReadingSpeed,t.pitch=1,t.text=e.text,t.lang=e.lang||t.voice.lang,t.payload=e.payload||"",e.onend&&(t.onend=e.onend),e.onerror&&(t.onerror=e.onerror),e.onpause&&(t.onpause=e.onpause),e.onresume&&(t.onresume=e.onresume),e.onmark&&(t.onmark=e.onmark),e.onboundary&&(t.onboundary=e.onboundary),void speechSynthesis.speak(t))}var o=n(1),a={word_list:[],crt:0,initialized:0,crtWord:"",lastWords:[],onCancel:function(){},onEnd:function(){},onWord:function(e,t){},init:function(e){this.word_list=e,this.crt=0;window.speechSynthesis.getVoices();this.initialized=1},speak:function(){var e=this.selectChunk(),t=this;console.log("speak() run window.isSpeaking=",window.isSpeaking),setTimeout(function(){i({voice:o.defaultVoice,text:e,speed:o.defaultReadingSpeed,onend:function(e){return t.crt<t.crtSent&&!window.isSpeaking?(console.log("speak self.onCancel("+t.crt+")"),t.onCancel(t.crt),void t.stop()):(t.crt++,void(t.crt<t.word_list.length&&window.isSpeaking?(console.log("speak self.speak() crt=",t.crt,"word_list.len=",t.word_list.length),console.log("speak() 3"),t.speak()):(console.log("speak onEnd() self.crt=",t.crt,"window.isSpeaking=",window.isSpeaking),t.onEnd(t.crt))))},onboundary:function(e){var n=e.currentTarget.text,u=e.charIndex,i=n.substr(u);console.log("speaker.crt=",dbg.speaker.crt,"ofs=",u,"text=",n);var o=n.split(/\s+/),a=o.length-i.split(/\s+/).length;t.crtWord=i.replace(/\s.*$/,"");var s=5,l=o.slice(a-s+1,a+1),c=o.slice(a,a+s);o.slice(a,a+s+3);console.log("prev_ngram=",l,"next_ngram=",c);var f=r(t.word_list,c,t.crt),d=r(t.word_list,l,t.crt-20);if(-1!=d||-1!=f){d>=0&&(d+=4),console.log("crtWord=",t.crtWord,"poz_prev=",d,"poz_next=",f);var h=-1;0>f&&d>=0?h=d:f>=0&&0>d?h=f:f>=0&&d>=0&&(h=Math.abs(t.crt-f)<Math.abs(t.crt-d)?f:d),0>h&&(h=a+1),h>=0&&(t.crt=h,t.onWord(t.crt,t.crtWord),console.log("next_ngram=",c,"poz=",h))}}})},0)},selectChunk:function(){for(var e=[],t=this.crt;t<this.word_list.length&&t<this.crt+o.maxChunkLen;t++){var n=this.word_list[t].word;if(n=n.replace(/[^\x20-\xffțășîâ’‘’“”"'_—]/gi,""),this.word_list[t].id&&"-filler-"!=this.word_list[t].id){var r=document.getElementsByClassName(this.word_list[t].id)[0];if(!u(r)){console.log("skipping hidden word2",this.word_list[t]);continue}}if(e.push(n),this.crtSent=t,(n.match(/[\.,]$/)||n.match(/^\s*\[\.\.\]\s*$/))&&e.length>=o.minChunkLen)break}var i=e.join(" ");return"ext"==ext_or_page&&(i=i.replace(/\s*\[.*?\]\s*/g," "),i=i.replace(/\s*\[.*et al.*$/g," "),i=i.replace(/^.*et al.*\]\s*/g," "),i=i.replace(/\s*\(.*?\)\s*/g," "),i=i.replace(/\s*\(.*et al.*$/g," "),i=i.replace(/^.*et al.*\)\s*/g," ")),console.log("chunk",i),i},skipToNextParagraph:function(){this.stop();for(var e=this.crt,t=0;e<this.word_list.length&&500>t;e++,t++)if(e>0&&this.word_list[e-1].word.match(/^\s*\[\.\.\]\s*$/)){this.crt=e;break}console.log("speak() 2"),this.speak(),window.isSpeaking=!0,console.log("SET4 isSpeaking",window.isSpeaking)},skipToPrevParagraph:function(){var e=!1;this.stop();for(var t=this.crt;t>0;t--)if(0==t||this.word_list[t-1].word.match(/^\s*\[\.\.\]\s*$/)){if(e){this.crt=t;break}e=!0}console.log("speak() 2 crt=",this.crt,"word=",this.word_list[t],"word-1=",this.word_list[t-1]),this.speak(),window.isSpeaking=!0,console.log("SET5 isSpeaking",window.isSpeaking)},stop:function(){window.isSpeaking=!1,console.log("SET6 isSpeaking",window.isSpeaking),speechSynthesis.cancel()}};a.speakChunk=i,e.exports=a}]);
@nafizh
Copy link

nafizh commented Apr 2, 2018

Thanks for this. Do you have any idea on how to make it work in linux?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment