javascript:(()=>{let e=0;const t=(()=>{const e=[],t=[],n={},o={},i={};function r(e){return"string"==typeof e?new RegExp(`^${e}$`,"iu"):e}function l(e,t){return e===t?t:e===e.toLowerCase()?t.toLowerCase():e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function s(e,t){return e.replace(t[0],(function(n,o){const i=(r=t[1],s=arguments,r.replace(/\$(\d{1,2})/gu,(function(e,t){return s[t]||""})));var r,s;return l(""===n?e[o-1]:n,i)}))}function c(e,t,o){if(!e.length||Object.prototype.hasOwnProperty.call(n,e))return t;let i=o.length;for(;i--;){const e=o[i];if(e[0].test(t))return s(t,e)}return t}function a(e,t,n){return function(o){const i=o.toLowerCase();return Object.prototype.hasOwnProperty.call(t,i)?l(o,i):Object.prototype.hasOwnProperty.call(e,i)?l(o,e[i]):c(i,o,n)}}function h(e,t,n){return function(o){const i=o.toLowerCase();return!!Object.prototype.hasOwnProperty.call(t,i)||!Object.prototype.hasOwnProperty.call(e,i)&&c(i,i,n)===i}}function u(e,t,n){return(n?`${t} `:"")+(1===t?u.singular(e):u.plural(e))}return u.plural=a(i,o,e),u.isPlural=h(i,o,e),u.singular=a(o,i,t),u.isSingular=h(o,i,t),u.addPluralRule=function(t,n){e.push([r(t),n])},u.addSingularRule=function(e,n){t.push([r(e),n])},u.addUncountableRule=function(e){"string"!=typeof e?(u.addPluralRule(e,"$0"),u.addSingularRule(e,"$0")):n[e.toLowerCase()]=!0},u.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),i[e]=t,o[t]=e},[["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["passerby","passersby"]].forEach((function(e){return u.addIrregularRule(e[0],e[1])})),[[/s?$/iu,"s"],[/[^\u0000-\u007F]$/iu,"$0"],[/([^aeiou]ese)$/iu,"$1"],[/(ax|test)is$/iu,"$1es"],[/(alias|[^aou]us|t[lm]as|gas|ris)$/iu,"$1es"],[/(e[mn]u)s?$/iu,"$1s"],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/iu,"$1"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/iu,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/iu,"$1ae"],[/(seraph|cherub)(?:im)?$/iu,"$1im"],[/(her|at|gr)o$/iu,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/iu,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/iu,"$1a"],[/sis$/iu,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/iu,"$1$2ves"],[/([^aeiouy]|qu)y$/iu,"$1ies"],[/([^ch][ieo][ln])ey$/iu,"$1ies"],[/(x|ch|ss|sh|zz)$/iu,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/iu,"$1ices"],[/\b((?:tit)?m|l)(?:ice|ouse)$/iu,"$1ice"],[/(pe)(?:rson|ople)$/iu,"$1ople"],[/(child)(?:ren)?$/iu,"$1ren"],[/eaux$/iu,"$0"],[/m[ae]n$/iu,"men"],["thou","you"]].forEach((function(e){return u.addPluralRule(e[0],e[1])})),[[/(ss)$/iu,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/iu,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/iu,"$1f"],[/ies$/iu,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/iu,"$1ie"],[/\b(mon|smil)ies$/iu,"$1ey"],[/\b((?:tit)?m|l)ice$/iu,"$1ouse"],[/(seraph|cherub)im$/iu,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/iu,"$1"],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/iu,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/iu,"$1"],[/(test)(?:is|es)$/iu,"$1is"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/iu,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/iu,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/iu,"$1on"],[/(alumn|alg|vertebr)ae$/iu,"$1a"],[/(cod|mur|sil|vert|ind)ices$/iu,"$1ex"],[/(matr|append)ices$/iu,"$1ix"],[/(pe)(rson|ople)$/iu,"$1rson"],[/(child)ren$/iu,"$1"],[/(eau)x?$/iu,"$1"],[/men$/iu,"man"]].forEach((function(e){return u.addSingularRule(e[0],e[1])})),["as","adulthood","advice","agenda","aid","aircraft","alcohol","ammo","analytics","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","firmware","flounder","fun","gallows","garbage","graffiti","hardware","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","mud","manga","news","only","personnel","pike","plankton","pliers","police","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","software","species","staff","swine","tennis","traffic","transportation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/pok[eé]mon$/iu,/[^aeiou]ese$/iu,/deer$/iu,/fish$/iu,/measles$/iu,/o[iu]s$/iu,/pox$/iu,/sheep$/iu].forEach(u.addUncountableRule),u})(),n=e=>{if(!e)return!1;const t=e.getBoundingClientRect();return 0!==t.height&&0!==t.width},o=(e,t)=>{const n=e.previousSibling,o=e.parentElement;e.remove(),n?n.after(...t):o?.prepend(...t)},i=e=>e.replaceAll(/[a-zA-Z]+/gu,(e=>t.singular(e))),r={一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},l=e=>(e=>e.replace(/[一二三四五六七八九]/gu,(e=>r[e])))((e=>e.replace(/[ァ-ン]/gu,(e=>String.fromCharCode(e.charCodeAt(0)-96))).replaceAll("ゐ","い").replaceAll("ゑ","え"))((e=>e.replace(/[!-~]/gu,(e=>String.fromCharCode(e.charCodeAt(0)-65248))))(i(e).replaceAll(/\s+/gu,"")))).toLowerCase(),s=(e,t,{f_include_end_spaces:n=!1}={})=>{const o=t.split(/([^a-zA-Z]+)/u).map((e=>[e.length,i(e).length])),r=i(t);let l,s=r.substring(0,e).match(/\s/gu)?.length??0,c=e;for(;s;)l=r[c],/^\s$/u.test(l)||(s-=1),c+=1;if(n)for(l=r[c];/^\s$/u.test(l);)c+=1,l=r[c];let a=c,h=0;for(let e=0;ec)break;a+=t[0]-t[1]}return a},c=(e,t,o)=>{switch(e.nodeType){case Node.ELEMENT_NODE:{if(["SCRIPT","STYLE"].includes(e.nodeName.toLocaleUpperCase()))return;const n=e.childNodes;for(let e=0;e{switch(e.nodeType){case Node.ELEMENT_NODE:{if(["SCRIPT","STYLE"].includes(e.nodeName.toLocaleUpperCase()))return;const n=e.contentDocument?.body?.childNodes;if(n)for(let e=0;e{for(let i=0;i=e:r.index_to>e)return n?r:i}throw new Error(`not found at get_text_object(${e}) `)},u=(e,t)=>1===e?"1":`${e} (↑${t}↓${e-t-1})`,g=(e,t,n,o,i)=>{const{n_counter2:r}=i,l=t%n,s=document.createElement("mark");return s.classList.add("highlight_selection",`highlight_selection_${l}`,`highlight_selection_serial_${t}`),s.textContent=e,s.dataset.s_count_highlights=u(o,r),s},d=(e,t,n,o)=>{const i=[],{node:r}=e,{textContent:l}=r,c=e.custom_ranges.sort(((e,t)=>e.start>t.start?1:-1));let a,h,u=0;for(let e=0;e1===e.custom_ranges.length&&e.custom_ranges[0].f_is_highlighted&&e.custom_ranges[0].f_is_equal_text,m=(e,t,n)=>{const{n_counter2:o}=n.custom_ranges[0];e.dataset.s_count_highlights=u(t,o)},p=(e,t)=>{const n=[];a(document.body,n),(e=>{let t=0;for(let n=0;n{const n=new RegExp(e.replace(/[()[\]{}*+.$^\\|?]/gu,"\\$&"),"gui");return[...t.matchAll(n)].map((e=>e.index))})(e,n.map((e=>e.s_text)).join("")),r=((e,t,n)=>{const o=[];for(let i=0;i{const r=new Map;for(let s=0;s{let t=-1,n=-1;for(let o=0;ot?(t=o.n_counter,n++,o.n_counter2=n):o.n_counter2=n}}return n+1})(c);for(let e=0;e{const t=`.highlight_selection_serial_${e}`,n=document.querySelector(t);if(!n)return;const o=l(n.textContent);p(o,e)},b=()=>{if(Object.hasOwn(window,"M_highlight_selection_observer_controller")&&window.M_highlight_selection_observer_controller.disconnect(),void 0===document.documentElement.dataset.n_highlight_selection_serial_color_current)return;const e=Number(document.documentElement.dataset.n_highlight_selection_serial_color_current);for(let t=0;t<=e;t++)f(t);Object.hasOwn(window,"M_highlight_selection_observer_controller")&&window.M_highlight_selection_observer_controller.reconnect()},$=()=>{console.log("highlight_selection_bookmark.js: v1.4.0"),e=0,Object.hasOwn(window,"M_highlight_selection_observer_controller")&&window.M_highlight_selection_observer_controller.disconnect(),(()=>{let e=document.querySelector("iframe");if(!e){if(e=document.createElement("iframe"),!e)return;e.style.display="none",document.body.append(e)}try{console.log=e.contentWindow?.console.log}catch(t){e=document.createElement("iframe"),e.style.display="none",document.body.append(e);try{console.log=e.contentWindow?.console.log}catch(e){}}})(),document.querySelector("#highlight_selection_style")||document.head.insertAdjacentHTML("beforeend",'\n'),document.querySelector("#highlight_selection_svg_template")||document.body.insertAdjacentHTML("afterbegin",'');const t=(()=>{const e=getSelection();if(!e||!e.rangeCount)return;const t=(e=>{const t=[];return c(e.commonAncestorContainer,t,e),l(t.join(""))})(e.getRangeAt(0));return""!==t?t:void 0})();if(!t)return;const n=(()=>{const e=document.documentElement.dataset.n_highlight_selection_serial_color_current;return void 0!==e?Number(e)+1:0})();p(t,n),(()=>{let e;document.documentElement.dataset.n_highlight_selection_serial_color_current||(document.addEventListener("mouseover",(t=>{const n=t.target;if(!n)throw new Error("!e_target at c_mouseover");if(n.classList.contains("highlight_selection")){if(t.stopPropagation(),t.stopImmediatePropagation(),clearTimeout(e),(e=>e.lastElementChild?.classList.contains("highlight_selection_close"))(n))return;document.querySelectorAll(".highlight_selection_close").forEach((e=>e.remove())),n.insertAdjacentHTML("beforeend",'');const i=n.querySelector(".highlight_selection_close");if(!i)throw new Error("Unexpected e_close. Never here.");const r=e=>{if(0!==e.button)return;e.stopPropagation(),e.stopImmediatePropagation();const t=i.closest(".highlight_selection");if(!t)throw new Error("Unexpected e_highlight_selection. Never here.");Object.hasOwn(window,"M_highlight_selection_observer_controller")&&window.M_highlight_selection_observer_controller.disconnect(),i.remove(),(e=>{const t=e.className.match(/\bhighlight_selection_serial_(\d+)\b/u)[1],n=document.querySelectorAll(`.highlight_selection_serial_${t}`);for(let e=0;e{n.removeEventListener("mouseleave",e),i.removeEventListener("mousedown",r,{capture:!0}),i.remove()},s=()=>{e=setTimeout((()=>l(s)),500)};n.addEventListener("mouseleave",s)}}),{capture:!0}),document.addEventListener("dblclick",(e=>{const t=e.target?.closest(".highlight_selection");if(!t)return;e.preventDefault();const n=getSelection();n?.selectAllChildren(t)}),{capture:!0}))})(),(t=>{document.documentElement.dataset.n_highlight_selection_serial_color_current=String(t),getSelection()?.empty(),Object.hasOwn(window,"M_highlight_selection_observer_controller")&&window.M_highlight_selection_observer_controller.reconnect(),Object.hasOwn(window,"M_highlight_selection_observer_controller")||(window.M_highlight_selection_observer_controller=((t,n=2e3,o=document)=>{let i=null;const r={attributes:!1,characterData:!1,childList:!0,subtree:!0},l=new MutationObserver((o=>{o.every((e=>0===e.addedNodes.length))||o.some((e=>e.addedNodes[0]?.className?.toLowerCase().includes("highlight_selection")))||"fixed"!==o[0]?.addedNodes[0]?.style?.position&&(clearTimeout(i),e<10&&(i=setTimeout((()=>{t(),e+=1}),n)))}));return l.observe(o,r),{disconnect:()=>{l.disconnect()},reconnect:()=>{l.observe(o,r)}}})(b))})(n)};"undefined"==typeof chrome||void 0===chrome.runtime?$():chrome.runtime.onMessage.addListener(((e,t,n)=>{"highlight_selection"===e&&($(),n("done"))}))})();