forked from hoyois/html5outliner
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbookmarklet-minified.js
More file actions
1 lines (1 loc) · 6.6 KB
/
bookmarklet-minified.js
File metadata and controls
1 lines (1 loc) · 6.6 KB
1
(function(){var numbering=0001,linkColor='',clickOutside=true,showDetails=false,i=['#h5o-outside,#h5o-outside *{background-color:transparent;border:none;border-radius:0;bottom:auto;box-shadow:none;box-sizing:content-box;clear:none;'+(linkColor?'color:'+linkColor+';':'')+'cursor:auto;direction:ltr;float:none;font-family:sans-serif;font-size:small;font-stretch:normal;font-style:normal;font-variant:normal;font-weight:normal;height:auto;left:auto;letter-spacing:normal;line-height:normal;margin:0;opacity:1;outline:none;overflow:visible;padding:0;position:static;right:auto;text-align:left;text-decoration:none;text-indent:0;text-overflow:clip;text-shadow:none;text-transform:none;top:auto;vertical-align:baseline;visibility:visible;white-space:normal;width:auto;word-break:normal;word-spacing:normal;word-wrap:normal;zoom:normal;}','#h5o-inside *:not([href]){color:black;}','#h5o-outside{background-color:transparent;box-sizing:border-box;display:block;height:100%;padding:10px;pointer-events:none;position:fixed;right:0px;top:0px;max-width:500px;z-index:2147483647;}','#h5o-inside{background-color:white;border:2px solid black;box-sizing:border-box;display:block;max-width:100%;max-height:100%;opacity:.9;overflow:auto;padding:10px;pointer-events:auto;}','#h5o-inside ol{counter-reset:li;display:block;margin:0;padding:0;}','#h5o-inside li{counter-increment:li;display:list-item;list-style-type:none;margin-left:'+(numbering===2?'2em':'1.5em')+';position:relative;}','#h5o-inside a{display:inline;}','#h5o-inside a:hover{text-decoration:underline;}','#h5o-inside li.h5o-notitle>a{font-style:italic;}'];if(numbering>0)i.push('#h5o-inside li::before{content:'+(numbering===2?'counters(li,".")':'counter(li)')+'".";display:block;left:-10.5em;position:absolute;text-align:right;width:10em;}');else i.push('#h5o-inside>ol>li{margin-left:0;}');function l(e){var t=document.createElement('ol');for(var n=0;n<e.length;n++){t.appendChild(c(e[n]))}return t}function c(e){var t=document.createElement('li');var n=document.createElement('a');t.appendChild(n);if(e.heading===null||/^[ \r\n\t]*$/.test(e.heading.text)){t.className='h5o-notitle';switch(e.associatedNodes[0].nodeName.toLowerCase()){case'body':n.textContent='Document';break;case'article':n.textContent='Article';break;case'aside':n.textContent='Sidebar';break;case'nav':n.textContent='Navigation';break;case'section':n.textContent='Section';break;default:n.textContent='Empty title'}}else n.textContent=e.heading.text;var i=e.explicit?e.associatedNodes[0]:e.heading;n.href='#'+i.id;n.addEventListener('click',function(e){e.preventDefault();i.scrollIntoView()},false);if(showDetails){var s='';if(e.explicit)s+='<'+e.associatedNodes[0].nodeName.toLowerCase()+'>';if(e.heading)s+='<h'+ -e.heading.rank+'>';s+=', '+e.associatedNodes.length+' nodes';n.title=s}t.appendChild(l(e.childSections));return t}function h(e){this.parentSection=null;this.childSections=[];this.firstChild=null;this.lastChild=null;this.appendChild=function(e){e.parentSection=this;this.childSections.push(e);if(this.firstChild===null)this.firstChild=e;this.lastChild=e};this.explicit=e;this.associatedNodes=[]}function p(e){function s(e){if(c(e)){if(!r.isEmpty()&&(b(r.top)||p(r.top))){}else if(p(e)){r.push(e)}else if(v(e)){if(t!==null){if(a(n))l(n);r.push(t)}t=e;n=new h(true);u(t,n);t.appendSection(n)}else if(d(e)){if(t!==null)r.push(t);t=e;t.parentSection=n;n=new h(true);u(t,n);t.appendSection(n)}else if(t===null){}else if(b(e)){if(a(n))n.heading=e;else if(f(t.lastSection)||e.rank>=t.lastSection.heading.rank){n=new h(false);n.heading=e;t.appendSection(n)}else{var i=n;while(e.rank>=i.heading.rank)i=i.parentSection;n=new h(false);n.heading=e;i.appendChild(n)}r.push(e)}}}function o(e){if(c(e)){if(!r.isEmpty()&&e===r.top)r.pop();else if(!r.isEmpty()&&(b(r.top)||p(r.top))){}else if(!r.isEmpty()&&v(e)){if(a(n))l(n);t=r.pop();n=t.lastSection;for(var i=0;i<e.sectionList.length;i++){n.appendChild(e.sectionList[i])}}else if(!r.isEmpty()&&d(e)){if(a(n))l(n);n=t.parentSection;t=r.pop()}else if(v(e)||d(e)){if(a(n))l(n);t=null;n=null}}if(e.associatedSection===null&&n!==null)u(e,n)}function u(e,t){t.associatedNodes.push(e);e.associatedSection=t}function a(e){return e.heading===undefined}function f(e){return e.heading===null}function l(e){e.heading=null}function c(e){return e.nodeType===1}function p(e){return e.hidden}function d(e){return["blockquote","body","details","dialog","fieldset","figure","td"].indexOf(e.nodeName.toLowerCase())!==-1}function v(e){return["article","aside","nav","section"].indexOf(e.nodeName.toLowerCase())!==-1}function m(e){return d(e)||v(e)}function g(e){return["h1","h2","h3","h4","h5","h6"].indexOf(e.nodeName.toLowerCase())!==-1}function y(e){return"hgroup"===e.nodeName.toLowerCase()}function b(e){return g(e)||y(e)}function w(e){if(m(e))S(e);else if(g(e))T(e);else if(y(e))N(e);else E(e)}function E(e){e.associatedSection=null}function S(e){E(e);e.sectionList=[];e.firstSection=null;e.lastSection=null;e.appendSection=function(e){this.sectionList.push(e);if(this.firstSection===null)this.firstSection=e;this.lastSection=e}}function x(e){E(e);Object.defineProperty(e,"depth",{get:function(){var t=e.associatedSection;if(t===null)return undefined;var n=1;while(t=t.parentSection)++n;return n},configurable:true,enumerable:true})}function T(e){x(e);e.rank=-parseInt(e.nodeName.charAt(1));e.text=e.textContent}function N(e){x(e);for(var t=1;t<=6;t++){var n=e.getElementsByTagName("h"+t);if(n.length>0){e.rank=-t;e.text=n[0].textContent;break}}if(e.rank===undefined){e.rank=-1;e.text=""}}var t=null;var n=null;var r={lastIndex:-1};r.isEmpty=function(){return r.lastIndex===-1};r.push=function(e){r[++r.lastIndex]=e;r.top=e};r.pop=function(){var e=r.top;delete r[r.lastIndex--];r.top=r[r.lastIndex];return e};var i=e;e:while(i){w(i);s(i);if(i.firstChild){i=i.firstChild;continue e}while(i){o(i);if(i===e)break e;if(i.nextSibling){i=i.nextSibling;continue e}i=i.parentNode}}}if(!window.h5o_sdWoNJpsAgQGAaf)window.h5o_sdWoNJpsAgQGAaf=function(){document.removeEventListener('click',h5o_sdWoNJpsAgQGAaf,false);document.body.removeChild(document.getElementById('h5o-outside'))};if(document.getElementById('h5o-outside')){h5o_sdWoNJpsAgQGAaf();return}var s=document.createElement('div');s.id='h5o-outside';var o=document.createElement('style');s.appendChild(o);document.body.appendChild(s);for(var u=0;u<i.length;u++){try{o.sheet.insertRule(i[u].replace(/;/g,' !important;'),u)}catch(a){}}var f=document.createElement('div');f.id='h5o-inside';if(clickOutside){f.addEventListener('click',function(e){e.stopPropagation()},false);document.addEventListener('click',h5o_sdWoNJpsAgQGAaf,false)}p(document.body);if(!document.body.sectionList)return;f.appendChild(l(document.body.sectionList));s.appendChild(f)})()