ShareShortcuts

Clip to Notes

Web Clip to Notes shortcut

timfidd
„Clip to Notes“ forken

Hast du auf Basis dieses Kurzbefehls etwas Neues erstellt? Teile ihn als Fork: Er wird zu deinem eigenen Kurzbefehl, den du selbst verwaltest, und beide Seiten verlinken aufeinander, damit timfidd die Anerkennung erhält.

  1. 1Lade den Kurzbefehl und ändere ihn in der Kurzbefehle-App. Gib ihm einen eigenen Namen.
  2. 2Teile ihn in der Kurzbefehle-App und kopiere den iCloud-Link.
  3. 3Komm hierher zurück, füge den Link ein und beschreibe, was sich geändert hat, z. B. „Einen Schritt hinzugefügt, der Apple Intelligence nutzt, um den Text zu personalisieren.“
Downloads
20K
Gesichert
1
Aktionen
34
Kategorie
Utilities
Version
1.0
Sprache
EN

Web Clip to Notes shortcut. Clip pages from the web into Apple Notes. Fast with good readable / render reproduction, using Mozilla’s readability.js

Invoke from the share sheet from mobile Safari (JavaScript needs to be enabled). Optionally from a bookmark bookmarklet (not included here).

Neue Funktionen

Version 1.0

First release

Versionsverlauf
1.0 25. Sep 2024

First release

Was er macht

34 Aktionen
  1. Count
  2. If
  3. Comment
    If shortcut input is via the sharesheet, run javascript
  4. Run JavaScript on Web Page
  5. Set Variable
    Clip
  6. If
  7. Comment
    Shortcut input is clipboard from bookmarklet
  8. Get Clipboard
  9. Set Variable
    Clip
  10. Split Text
  11. Repeat with Each
  12. Text
  13. Combine Text
  14. Set Variable
    Content
  15. Comment
    If pass of Clip variable has no value, either split text failed, or content has encoding that is not parsable or CSP is enforced. Use Clip directly and accept formatting as is.
  16. If
  17. Set Variable
    Content
  18. If
  19. Comment
    Notes renders level 3 headers as bold and not subheadings. Replace with level 2.
  20. Replace Text
  21. Set Variable
    Content
  22. Make Rich Text from Markdown
  23. Date
  24. Format Date
  25. Text
  26. Make Rich Text from HTML
  27. List
  28. Combine Text
  29. Append to Note
  30. Comment
    Best to run this shortcut from the share sheet or using the bookmarklet, using Safari and Notes in split view, or Notes in Slide over. If shortcut input is 0 then Clip to Notes was invoked from the bookmarklet. Open the Note so we dont end up in the…
  31. If
  32. Open Note
  33. If
  34. Stop and Output

Als Code ansehen
Beta

Jede Aktion dieses Kurzbefehls als Cherri ausgeschrieben, eine Programmiersprache für Kurzbefehle. Ideal, um zu lernen, wie er funktioniert.

#include 'actions/web'
#define color yellow
#define glyph noteTextPlus

const Count = count(ShortcutInput)

if Count == 1 {
	// If shortcut input is via the sharesheet, run javascript

	runJavaScriptOnWebpage("const vault=\"\",folder=\"/\";let tags=\"\";function Readability(e,t){if(t&&t.documentElement)e=t,t=arguments[2];else if(!e||!e.documentElement)throw new Error(\"First argument to Readability constructor should be a document object.\");let n;t=t||{},this._doc=e,this._docJSDOMParser=this._doc.firstChild.__JSDOMParser__,this._articleTitle=null,this._articleByline=null,this._articleDir=null,this._articleSiteName=null,this._attempts=[],this._debug=!!t.debug,this._maxElemsToParse=t.maxElemsToParse||this.DEFAULT_MAX_ELEMS_TO_PARSE,this._nbTopCandidates=t.nbTopCandidates||this.DEFAULT_N_TOP_CANDIDATES,this._charThreshold=t.charThreshold||this.DEFAULT_CHAR_THRESHOLD,this._classesToPreserve=this.CLASSES_TO_PRESERVE.concat(t.classesToPreserve||[]),this._keepClasses=!!t.keepClasses,this._flags=this.FLAG_STRIP_UNLIKELYS|this.FLAG_WEIGHT_CLASSES|this.FLAG_CLEAN_CONDITIONALLY,this._debug?(n=function(e){const t=e.nodeName+\" \";if(e.nodeType==e.TEXT_NODE)return t+'(\"'+e.textContent+'\")';const n=e.className&&\".\"+e.className.replace(/ /g,\".\");let i=\"\";return e.id?i=\"(#\"+e.id+n+\")\":n&&(i=\"(\"+n+\")\"),t+i},this.log=function(){if(\"undefined\"!=typeof dump){const e=Array.prototype.map.call(arguments,(e=>e&&e.nodeName?n(e):e)).join(\" \");dump(\"Reader: (Readability) \"+e+\"\n\")}else if(\"undefined\"!=typeof console){const e=[\"Reader: (Readability) \"].concat(arguments);console.log.apply(console,e)}}):this.log=function(){}}function extend(e){for(let t=1;t<arguments.length;t++){const n=arguments[t];for(const t in n)n.hasOwnProperty(t)&&(e[t]=n[t])}return e}function repeat(e,t){return Array(t+1).join(e)}Readability.prototype={FLAG_STRIP_UNLIKELYS:1,FLAG_WEIGHT_CLASSES:2,FLAG_CLEAN_CONDITIONALLY:4,ELEMENT_NODE:1,TEXT_NODE:3,DEFAULT_MAX_ELEMS_TO_PARSE:0,DEFAULT_N_TOP_CANDIDATES:5,DEFAULT_TAGS_TO_SCORE:\"section,h2,h3,h4,h5,h6,p,td,pre\".toUpperCase().split(\",\"),DEFAULT_CHAR_THRESHOLD:500,REGEXPS:{unlikelyCandidates:/-ad-|ai2html|banner|breadcrumbs|combx|comment|community|cover-wrap|disqus|extra|footer|gdpr|header|legends|menu|related|remark|replies|rss|shoutbox|sidebar|skyscraper|social|sponsor|supplemental|ad-break|agegate|pagination|pager|popup|yom-remote/i,okMaybeItsACandidate:/and|article|body|column|content|main|shadow/i,positive:/article|body|content|entry|hentry|h-entry|main|page|pagination|post|text|blog|story/i,negative:/hidden|^hid$| hid$| hid |^hid |banner|combx|comment|com-|contact|foot|footer|footnote|gdpr|masthead|media|meta|outbrain|promo|related|scroll|share|shoutbox|sidebar|skyscraper|sponsor|shopping|tags|tool|widget/i,extraneous:/print|archive|comment|discuss|e[\-]?mail|share|reply|all|login|sign|single|utility/i,byline:/byline|author|dateline|writtenby|p-author/i,replaceFonts:/<(\/?)font[^>]*>/gi,normalize:/\s{2,}/g,videos:/\/\/(www\.)?((dailymotion|youtube|youtube-nocookie|player\.vimeo|v\.qq)\.com|(archive|upload\.wikimedia)\.org|player\.twitch\.tv)/i,shareElements:/(\b|_)(share|sharedaddy)(\b|_)/i,nextLink:/(next|weiter|continue|>([^\|]|$)|»([^\|]|$))/i,prevLink:/(prev|earl|old|new|<|«)/i,whitespace:/^\s*$/,hasContent:/\S$/,srcsetUrl:/(\S+)(\s+[\d.]+[xw])?(\s*(?:,|$))/g,b64DataUrl:/^data:\s*([^\s;,]+)\s*;\s*base64\s*,/i},DIV_TO_P_ELEMS:[\"A\",\"BLOCKQUOTE\",\"DL\",\"DIV\",\"IMG\",\"OL\",\"P\",\"PRE\",\"TABLE\",\"UL\",\"SELECT\"],ALTER_TO_DIV_EXCEPTIONS:[\"DIV\",\"ARTICLE\",\"SECTION\",\"P\"],PRESENTATIONAL_ATTRIBUTES:[\"align\",\"background\",\"bgcolor\",\"border\",\"cellpadding\",\"cellspacing\",\"frame\",\"hspace\",\"rules\",\"style\",\"valign\",\"vspace\"],DEPRECATED_SIZE_ATTRIBUTE_ELEMS:[\"TABLE\",\"TH\",\"TD\",\"HR\",\"PRE\"],PHRASING_ELEMS:[\"ABBR\",\"AUDIO\",\"B\",\"BDO\",\"BR\",\"BUTTON\",\"CITE\",\"CODE\",\"DATA\",\"DATALIST\",\"DFN\",\"EM\",\"EMBED\",\"I\",\"IMG\",\"INPUT\",\"KBD\",\"LABEL\",\"MARK\",\"MATH\",\"METER\",\"NOSCRIPT\",\"OBJECT\",\"OUTPUT\",\"PROGRESS\",\"Q\",\"RUBY\",\"SAMP\",\"SCRIPT\",\"SELECT\",\"SMALL\",\"SPAN\",\"STRONG\",\"SUB\",\"SUP\",\"TEXTAREA\",\"TIME\",\"VAR\",\"WBR\"],CLASSES_TO_PRESERVE:[\"page\"],HTML_ESCAPE_MAP:{lt:\"<\",gt:\">\",amp:\"&\",quot:'\"',apos:\"'\"},_postProcessContent(e){this._fixRelativeUris(e),this._keepClasses||this._cleanClasses(e)},_removeNodes(e,t){if(this._docJSDOMParser&&e._isLiveNodeList)throw new Error(\"Do not pass live node lists to _removeNodes\");for(let n=e.length-1;n>=0;n--){const i=e[n],r=i.parentNode;r&&(t&&!t.call(this,i,n,e)||r.removeChild(i))}},_replaceNodeTags(e,t){if(this._docJSDOMParser&&e._isLiveNodeList)throw new Error(\"Do not pass live node lists to _replaceNodeTags\");for(let n=e.length-1;n>=0;n--){const i=e[n];this._setNodeTag(i,t)}},_forEachNode(e,t){Array.prototype.forEach.call(e,t,this)},_someNode(e,t){return Array.prototype.some.call(e,t,this)},_everyNode(e,t){return Array.prototype.every.call(e,t,this)},_concatNodeLists(){const e=Array.prototype.slice,t=e.call(arguments).map((t=>e.call(t)));return Array.prototype.concat.apply([],t)},_getAllNodesWithTag:(e,t)=>e.querySelectorAll?e.querySelectorAll(t.join(\",\")):[].concat.apply([],t.map((t=>{const n=e.getElementsByTagName(t);return Array.isArray(n)?n:Array.from(n)}))),_cleanClasses(e){const t=this._classesToPreserve,n=(e.getAttribute(\"class\")||\"\").split(/\s+/).filter((e=>-1!=t.indexOf(e))).join(\" \");for(n?e.setAttribute(\"class\",n):e.removeAttribute(\"class\"),e=e.firstElementChild;e;e=e.nextElementSibling)this._cleanClasses(e)},_fixRelativeUris(e){const t=this._doc.baseURI,n=this._doc.documentURI;function i(e){if(t==n&&\"#\"==e.charAt(0))return e;try{return new URL(e,t).href}catch(e){}return e}const r=this._getAllNodesWithTag(e,[\"a\"]);this._forEachNode(r,(function(e){const t=e.getAttribute(\"href\");if(t)if(0===t.indexOf(\"javascript:\"))if(1===e.childNodes.length&&e.childNodes[0].nodeType===this.TEXT_NODE){const t=this._doc.createTextNode(e.textContent);e.parentNode.replaceChild(t,e)}else{const t=this._doc.createElement(\"span\");for(;e.childNodes.length>0;)t.appendChild(e.childNodes[0]);e.parentNode.replaceChild(t,e)}else e.setAttribute(\"href\",i(t))}));const s=this._getAllNodesWithTag(e,[\"img\",\"picture\",\"figure\",\"video\",\"audio\",\"source\"]);this._forEachNode(s,(function(e){const t=e.getAttribute(\"src\"),n=e.getAttribute(\"poster\"),r=e.getAttribute(\"srcset\");if(t&&e.setAttribute(\"src\",i(t)),n&&e.setAttribute(\"poster\",i(n)),r){const t=r.replace(this.REGEXPS.srcsetUrl,((e,t,n,r)=>i(t)+(n||\"\")+r));e.setAttribute(\"srcset\",t)}}))},_getArticleTitle(){const e=this._doc;let t=\"\",n=\"\";try{t=n=e.title.trim(),\"string\"!=typeof t&&(t=n=this._getInnerText(e.getElementsByTagName(\"title\")[0]))}catch(e){}let i=!1;function r(e){return e.split(/\s+/).length}if(/ [\|\-\\\/>»] /.test(t))i=/ [\\\/>»] /.test(t),t=n.replace(/(.*)[\|\-\\\/>»] .*/gi,\"$1\"),r(t)<3&&(t=n.replace(/[^\|\-\\\/>»]*[\|\-\\\/>»](.*)/gi,\"$1\"));else if(-1!==t.indexOf(\": \")){const i=this._concatNodeLists(e.getElementsByTagName(\"h1\"),e.getElementsByTagName(\"h2\")),s=t.trim();this._someNode(i,(e=>e.textContent.trim()===s))||(t=n.substring(n.lastIndexOf(\":\")+1),r(t)<3?t=n.substring(n.indexOf(\":\")+1):r(n.substr(0,n.indexOf(\":\")))>5&&(t=n))}else if(t.length>150||t.length<15){const n=e.getElementsByTagName(\"h1\");1===n.length&&(t=this._getInnerText(n[0]))}t=t.trim().replace(this.REGEXPS.normalize,\" \");const s=r(t);return s<=4&&(!i||s!=r(n.replace(/[\|\-\\\/>»]+/g,\"\"))-1)&&(t=n),t},_prepDocument(){const e=this._doc;this._removeNodes(this._getAllNodesWithTag(e,[\"style\"])),e.body&&this._replaceBrs(e.body),this._replaceNodeTags(this._getAllNodesWithTag(e,[\"font\"]),\"SPAN\")},_nextElement(e){let t=e;for(;t&&t.nodeType!=this.ELEMENT_NODE&&this.REGEXPS.whitespace.test(t.textContent);)t=t.nextSibling;return t},_replaceBrs(e){this._forEachNode(this._getAllNodesWithTag(e,[\"br\"]),(function(e){let t=e.nextSibling,n=!1;for(;(t=this._nextElement(t))&&\"BR\"==t.tagName;){n=!0;const e=t.nextSibling;t.parentNode.removeChild(t),t=e}if(n){const n=this._doc.createElement(\"p\");for(e.parentNode.replaceChild(n,e),t=n.nextSibling;t;){if(\"BR\"==t.tagName){const e=this._nextElement(t.nextSibling);if(e&&\"BR\"==e.tagName)break}if(!this._isPhrasingContent(t))break;const e=t.nextSibling;n.appendChild(t),t=e}for(;n.lastChild&&this._isWhitespace(n.lastChild);)n.removeChild(n.lastChild);\"P\"===n.parentNode.tagName&&this._setNodeTag(n.parentNode,\"DIV\")}}))},_setNodeTag(e,t){if(this.log(\"_setNodeTag\",e,t),this._docJSDOMParser)return e.localName=t.toLowerCase(),e.tagName=t.toUpperCase(),e;const n=e.ownerDocument.createElement(t);for(;e.firstChild;)n.appendChild(e.firstChild);e.parentNode.replaceChild(n,e),e.readability&&(n.readability=e.readability);for(let t=0;t<e.attributes.length;t++)try{n.setAttribute(e.attributes[t].name,e.attributes[t].value)}catch(e){}return n},_prepArticle(e){this._cleanStyles(e),this._markDataTables(e),this._fixLazyImages(e),this._cleanConditionally(e,\"form\"),this._cleanConditionally(e,\"fieldset\"),this._clean(e,\"object\"),this._clean(e,\"embed\"),this._clean(e,\"h1\"),this._clean(e,\"footer\"),this._clean(e,\"link\"),this._clean(e,\"aside\");const t=this.DEFAULT_CHAR_THRESHOLD;this._forEachNode(e.children,(function(e){this._cleanMatchedNodes(e,(function(e,n){return this.REGEXPS.shareElements.test(n)&&e.textContent.length<t}))}));const n=e.getElementsByTagName(\"h2\");if(1===n.length){const t=(n[0].textContent.length-this._articleTitle.length)/this._articleTitle.length;if(Math.abs(t)<.5){let i=!1;i=t>0?n[0].textContent.includes(this._articleTitle):this._articleTitle.includes(n[0].textContent),i&&this._clean(e,\"h2\")}}this._clean(e,\"iframe\"),this._clean(e,\"input\"),this._clean(e,\"textarea\"),this._clean(e,\"select\"),this._clean(e,\"button\"),this._cleanHeaders(e),this._cleanConditionally(e,\"table\"),this._cleanConditionally(e,\"ul\"),this._cleanConditionally(e,\"div\"),this._removeNodes(this._getAllNodesWithTag(e,[\"p\"]),(function(e){return 0===e.getElementsByTagName(\"img\").length+e.getElementsByTagName(\"embed\").length+e.getElementsByTagName(\"object\").length+e.getElementsByTagName(\"iframe\").length&&!this._getInnerText(e,!1)})),this._forEachNode(this._getAllNodesWithTag(e,[\"br\"]),(function(e){const t=this._nextElement(e.nextSibling);t&&\"P\"==t.tagName&&e.parentNode.removeChild(e)})),this._forEachNode(this._getAllNodesWithTag(e,[\"table\"]),(function(e){const t=this._hasSingleTagInsideElement(e,\"TBODY\")?e.firstElementChild:e;if(this._hasSingleTagInsideElement(t,\"TR\")){const n=t.firstElementChild;if(this._hasSingleTagInsideElement(n,\"TD\")){let t=n.firstElementChild;t=this._setNodeTag(t,this._everyNode(t.childNodes,this._isPhrasingContent)?\"P\":\"DIV\"),e.parentNode.replaceChild(t,e)}}}))},_initializeNode(e){switch(e.readability={contentScore:0},e.tagName){case\"DIV\":e.readability.contentScore+=5;break;case\"PRE\":case\"TD\":case\"BLOCKQUOTE\":e.readability.contentScore+=3;break;case\"ADDRESS\":case\"OL\":case\"UL\":case\"DL\":case\"DD\":case\"DT\":case\"LI\":case\"FORM\":e.readability.contentScore-=3;break;case\"H1\":case\"H2\":case\"H3\":case\"H4\":case\"H5\":case\"H6\":case\"TH\":e.readability.contentScore-=5}e.readability.contentScore+=this._getClassWeight(e)},_removeAndGetNext(e){const t=this._getNextNode(e,!0);return e.parentNode.removeChild(e),t},_getNextNode(e,t){if(!t&&e.firstElementChild)return e.firstElementChild;if(e.nextElementSibling)return e.nextElementSibling;do{e=e.parentNode}while(e&&!e.nextElementSibling);return e&&e.nextElementSibling},_checkByline(e,t){if(this._articleByline)return!1;if(void 0!==e.getAttribute)var n=e.getAttribute(\"rel\"),i=e.getAttribute(\"itemprop\");return!(!(\"author\"===n||i&&-1!==i.indexOf(\"author\")||this.REGEXPS.byline.test(t))||!this._isValidByline(e.textContent))&&(this._articleByline=e.textContent.trim(),!0)},_getNodeAncestors(e,t){t=t||0;let n=0,i=[];for(;e.parentNode&&(i.push(e.parentNode),!t||++n!==t);)e=e.parentNode;return i},_grabArticle(e){this.log(\"**** grabArticle ****\");const t=this._doc,n=null!==e;if(!(e=e||this._doc.body))return this.log(\"No body found in document. Abort.\"),null;const i=e.innerHTML;for(;;){const a=this._flagIsActive(this.FLAG_STRIP_UNLIKELYS),o=[];let l=this._doc.documentElement;for(;l;){const e=l.className+\" \"+l.id;if(this._isProbablyVisible(l))if(this._checkByline(l,e))l=this._removeAndGetNext(l);else{if(a){if(this.REGEXPS.unlikelyCandidates.test(e)&&!this.REGEXPS.okMaybeItsACandidate.test(e)&&!this._hasAncestorTag(l,\"table\")&&\"BODY\"!==l.tagName&&\"A\"!==l.tagName){this.log(\"Removing unlikely candidate - \"+e),l=this._removeAndGetNext(l);continue}if(\"complementary\"==l.getAttribute(\"role\")){this.log(\"Removing complementary content - \"+e),l=this._removeAndGetNext(l);continue}}if(\"DIV\"!==l.tagName&&\"SECTION\"!==l.tagName&&\"HEADER\"!==l.tagName&&\"H1\"!==l.tagName&&\"H2\"!==l.tagName&&\"H3\"!==l.tagName&&\"H4\"!==l.tagName&&\"H5\"!==l.tagName&&\"H6\"!==l.tagName||!this._isElementWithoutContent(l)){if(-1!==this.DEFAULT_TAGS_TO_SCORE.indexOf(l.tagName)&&o.push(l),\"DIV\"===l.tagName){let e=null,n=l.firstChild;for(;n;){const i=n.nextSibling;if(this._isPhrasingContent(n))null!==e?e.appendChild(n):this._isWhitespace(n)||(e=t.createElement(\"p\"),l.replaceChild(e,n),e.appendChild(n));else if(null!==e){for(;e.lastChild&&this._isWhitespace(e.lastChild);)e.removeChild(e.lastChild);e=null}n=i}if(this._hasSingleTagInsideElement(l,\"P\")&&this._getLinkDensity(l)<.25){const e=l.children[0];l.parentNode.replaceChild(e,l),l=e,o.push(l)}else this._hasChildBlockElement(l)||(l=this._setNodeTag(l,\"P\"),o.push(l))}l=this._getNextNode(l)}else l=this._removeAndGetNext(l)}else this.log(\"Removing hidden node - \"+e),l=this._removeAndGetNext(l)}var r=[];this._forEachNode(o,(function(e){if(!e.parentNode||void 0===e.parentNode.tagName)return;const t=this._getInnerText(e);if(t.length<25)return;const n=this._getNodeAncestors(e,3);if(0===n.length)return;let i=0;i+=1,i+=t.split(\",\").length,i+=Math.min(Math.floor(t.length/100),3),this._forEachNode(n,(function(e,t){if(e.tagName&&e.parentNode&&void 0!==e.parentNode.tagName){if(void 0===e.readability&&(this._initializeNode(e),r.push(e)),0===t)var n=1;else n=1===t?2:3*t;e.readability.contentScore+=i/n}}))}));const c=[];for(let e=0,t=r.length;e<t;e+=1){const t=r[e],n=t.readability.contentScore*(1-this._getLinkDensity(t));t.readability.contentScore=n,this.log(\"Candidate:\",t,\"with score \"+n);for(let e=0;e<this._nbTopCandidates;e++){const i=c[e];if(!i||n>i.readability.contentScore){c.splice(e,0,t),c.length>this._nbTopCandidates&&c.pop();break}}}let h=c[0]||null,d=!1;var s;if(null===h||\"BODY\"===h.tagName){h=t.createElement(\"DIV\"),d=!0;const n=e.childNodes;for(;n.length;)this.log(\"Moving child out:\",n[0]),h.appendChild(n[0]);e.appendChild(h),this._initializeNode(h)}else if(h){const e=[];for(let t=1;t<c.length;t++)c[t].readability.contentScore/h.readability.contentScore>=.75&&e.push(this._getNodeAncestors(c[t]));const t=3;if(e.length>=t)for(s=h.parentNode;\"BODY\"!==s.tagName;){let n=0;for(let i=0;i<e.length&&n<t;i++)n+=Number(e[i].includes(s));if(n>=t){h=s;break}s=s.parentNode}h.readability||this._initializeNode(h),s=h.parentNode;let n=h.readability.contentScore;const i=n/3;for(;\"BODY\"!==s.tagName;){if(!s.readability){s=s.parentNode;continue}const e=s.readability.contentScore;if(e<i)break;if(e>n){h=s;break}n=s.readability.contentScore,s=s.parentNode}for(s=h.parentNode;\"BODY\"!=s.tagName&&1==s.children.length;)h=s,s=h.parentNode;h.readability||this._initializeNode(h)}let g=t.createElement(\"DIV\");n&&(g.id=\"readability-content\");const u=Math.max(10,.2*h.readability.contentScore),m=(s=h.parentNode).children;for(let e=0,t=m.length;e<t;e++){let n=m[e],i=!1;if(this.log(\"Looking at sibling node:\",n,n.readability?\"with score \"+n.readability.contentScore:\"\"),this.log(\"Sibling has score\",n.readability?n.readability.contentScore:\"Unknown\"),n===h)i=!0;else{let e=0;if(n.className===h.className&&\"\"!==h.className&&(e+=.2*h.readability.contentScore),n.readability&&n.readability.contentScore+e>=u)i=!0;else if(\"P\"===n.nodeName){const e=this._getLinkDensity(n),t=this._getInnerText(n),r=t.length;(r>80&&e<.25||r<80&&r>0&&0===e&&-1!==t.search(/\.( |$)/))&&(i=!0)}}i&&(this.log(\"Appending node:\",n),-1===this.ALTER_TO_DIV_EXCEPTIONS.indexOf(n.nodeName)&&(this.log(\"Altering sibling:\",n,\"to div.\"),n=this._setNodeTag(n,\"DIV\")),g.appendChild(n),e-=1,t-=1)}if(this._debug&&this.log(\"Article content pre-prep: \"+g.innerHTML),this._prepArticle(g),this._debug&&this.log(\"Article content post-prep: \"+g.innerHTML),d)h.id=\"readability-page-1\",h.className=\"page\";else{const e=t.createElement(\"DIV\");e.id=\"readability-page-1\",e.className=\"page\";const n=g.childNodes;for(;n.length;)e.appendChild(n[0]);g.appendChild(e)}this._debug&&this.log(\"Article content after paging: \"+g.innerHTML);let p=!0;const f=this._getInnerText(g,!0).length;if(f<this._charThreshold)if(p=!1,e.innerHTML=i,this._flagIsActive(this.FLAG_STRIP_UNLIKELYS))this._removeFlag(this.FLAG_STRIP_UNLIKELYS),this._attempts.push({articleContent:g,textLength:f});else if(this._flagIsActive(this.FLAG_WEIGHT_CLASSES))this._removeFlag(this.FLAG_WEIGHT_CLASSES),this._attempts.push({articleContent:g,textLength:f});else if(this._flagIsActive(this.FLAG_CLEAN_CONDITIONALLY))this._removeFlag(this.FLAG_CLEAN_CONDITIONALLY),this._attempts.push({articleContent:g,textLength:f});else{if(this._attempts.push({articleContent:g,textLength:f}),this._attempts.sort(((e,t)=>t.textLength-e.textLength)),!this._attempts[0].textLength)return null;g=this._attempts[0].articleContent,p=!0}if(p){const e=[s,h].concat(this._getNodeAncestors(s));return this._someNode(e,(function(e){if(!e.tagName)return!1;const t=e.getAttribute(\"dir\");return!!t&&(this._articleDir=t,!0)})),g}}},_isValidByline:e=>(\"string\"==typeof e||e instanceof String)&&((e=e.trim()).length>0&&e.length<100),_unescapeHtmlEntities(e){if(!e)return e;const t=this.HTML_ESCAPE_MAP;return e.replace(/&(quot|amp|apos|lt|gt);/g,((e,n)=>t[n])).replace(/&#(?:x([0-9a-z]{1,4})|([0-9]{1,4}));/gi,((e,t,n)=>{const i=parseInt(t||n,t?16:10);return String.fromCharCode(i)}))},_getArticleMetadata(){const e={},t={},n=this._doc.getElementsByTagName(\"meta\"),i=/\s*(dc|dcterm|og|twitter)\s*:\s*(author|creator|description|title|site_name)\s*/gi,r=/^\s*(?:(dc|dcterm|og|twitter|weibo:(article|webpage))\s*[\.:]\s*)?(author|creator|description|title|site_name)\s*$/i;return this._forEachNode(n,(e=>{const n=e.getAttribute(\"name\"),s=e.getAttribute(\"property\"),a=e.getAttribute(\"content\");if(!a)return;let o=null,l=null;if(s&&(o=s.match(i),o))for(let e=o.length-1;e>=0;e--)l=o[e].toLowerCase().replace(/\s/g,\"\"),t[l]=a.trim();!o&&n&&r.test(n)&&(l=n,a&&(l=l.toLowerCase().replace(/\s/g,\"\").replace(/\./g,\":\"),t[l]=a.trim()))})),e.title=t[\"dc:title\"]||t[\"dcterm:title\"]||t[\"og:title\"]||t[\"weibo:article:title\"]||t[\"weibo:webpage:title\"]||t.title||t[\"twitter:title\"],e.title||(e.title=this._getArticleTitle()),e.byline=t[\"dc:creator\"]||t[\"dcterm:creator\"]||t.author,e.excerpt=t[\"dc:description\"]||t[\"dcterm:description\"]||t[\"og:description\"]||t[\"weibo:article:description\"]||t[\"weibo:webpage:description\"]||t.description||t[\"twitter:description\"],e.siteName=t[\"og:site_name\"],e.title=this._unescapeHtmlEntities(e.title),e.byline=this._unescapeHtmlEntities(e.byline),e.excerpt=this._unescapeHtmlEntities(e.excerpt),e.siteName=this._unescapeHtmlEntities(e.siteName),e},_isSingleImage(e){return\"IMG\"===e.tagName||1===e.children.length&&\"\"===e.textContent.trim()&&this._isSingleImage(e.children[0])},_unwrapNoscriptImages(e){const t=Array.from(e.getElementsByTagName(\"img\"));this._forEachNode(t,(e=>{for(let t=0;t<e.attributes.length;t++){const n=e.attributes[t];switch(n.name){case\"src\":case\"srcset\":case\"data-src\":case\"data-srcset\":return}if(/\.(jpg|jpeg|png|webp)/i.test(n.value))return}e.parentNode.removeChild(e)}));const n=Array.from(e.getElementsByTagName(\"noscript\"));this._forEachNode(n,(function(t){const n=e.createElement(\"div\");if(n.innerHTML=t.innerHTML,!this._isSingleImage(n))return;const i=t.previousElementSibling;if(i&&this._isSingleImage(i)){let e=i;\"IMG\"!==e.tagName&&(e=i.getElementsByTagName(\"img\")[0]);const r=n.getElementsByTagName(\"img\")[0];for(let t=0;t<e.attributes.length;t++){const n=e.attributes[t];if(\"\"!==n.value&&(\"src\"===n.name||\"srcset\"===n.name||/\.(jpg|jpeg|png|webp)/i.test(n.value))){if(r.getAttribute(n.name)===n.value)continue;let e=n.name;r.hasAttribute(e)&&(e=\"data-old-\"+e),r.setAttribute(e,n.value)}}t.parentNode.replaceChild(n.firstElementChild,i)}}))},_removeScripts(e){this._removeNodes(this._getAllNodesWithTag(e,[\"script\"]),(e=>(e.nodeValue=\"\",e.removeAttribute(\"src\"),!0))),this._removeNodes(this._getAllNodesWithTag(e,[\"noscript\"]))},_hasSingleTagInsideElement(e,t){return 1==e.children.length&&e.children[0].tagName===t&&!this._someNode(e.childNodes,(function(e){return e.nodeType===this.TEXT_NODE&&this.REGEXPS.hasContent.test(e.textContent)}))},_isElementWithoutContent(e){return e.nodeType===this.ELEMENT_NODE&&0==e.textContent.trim().length&&(0==e.children.length||e.children.length==e.getElementsByTagName(\"br\").length+e.getElementsByTagName(\"hr\").length)},_hasChildBlockElement(e){return this._someNode(e.childNodes,(function(e){return-1!==this.DIV_TO_P_ELEMS.indexOf(e.tagName)||this._hasChildBlockElement(e)}))},_isPhrasingContent(e){return e.nodeType===this.TEXT_NODE||-1!==this.PHRASING_ELEMS.indexOf(e.tagName)||(\"A\"===e.tagName||\"DEL\"===e.tagName||\"INS\"===e.tagName)&&this._everyNode(e.childNodes,this._isPhrasingContent)},_isWhitespace(e){return e.nodeType===this.TEXT_NODE&&0===e.textContent.trim().length||e.nodeType===this.ELEMENT_NODE&&\"BR\"===e.tagName},_getInnerText(e,t){t=void 0===t||t;const n=e.textContent.trim();return t?n.replace(this.REGEXPS.normalize,\" \"):n},_getCharCount(e,t){return t=t||\",\",this._getInnerText(e).split(t).length-1},_cleanStyles(e){if(!e||\"svg\"===e.tagName.toLowerCase())return;for(let t=0;t<this.PRESENTATIONAL_ATTRIBUTES.length;t++)e.removeAttribute(this.PRESENTATIONAL_ATTRIBUTES[t]);-1!==this.DEPRECATED_SIZE_ATTRIBUTE_ELEMS.indexOf(e.tagName)&&(e.removeAttribute(\"width\"),e.removeAttribute(\"height\"));let t=e.firstElementChild;for(;null!==t;)this._cleanStyles(t),t=t.nextElementSibling},_getLinkDensity(e){const t=this._getInnerText(e).length;if(0===t)return 0;let n=0;return this._forEachNode(e.getElementsByTagName(\"a\"),(function(e){n+=this._getInnerText(e).length})),n/t},_getClassWeight(e){if(!this._flagIsActive(this.FLAG_WEIGHT_CLASSES))return 0;let t=0;return\"string\"==typeof e.className&&\"\"!==e.className&&(this.REGEXPS.negative.test(e.className)&&(t-=25),this.REGEXPS.positive.test(e.className)&&(t+=25)),\"string\"==typeof e.id&&\"\"!==e.id&&(this.REGEXPS.negative.test(e.id)&&(t-=25),this.REGEXPS.positive.test(e.id)&&(t+=25)),t},_clean(e,t){const n=-1!==[\"object\",\"embed\",\"iframe\"].indexOf(t);this._removeNodes(this._getAllNodesWithTag(e,[t]),(function(e){if(n){for(let t=0;t<e.attributes.length;t++)if(this.REGEXPS.videos.test(e.attributes[t].value))return!1;if(\"object\"===e.tagName&&this.REGEXPS.videos.test(e.innerHTML))return!1}return!0}))},_hasAncestorTag(e,t,n,i){n=n||3,t=t.toUpperCase();let r=0;for(;e.parentNode;){if(n>0&&r>n)return!1;if(e.parentNode.tagName===t&&(!i||i(e.parentNode)))return!0;e=e.parentNode,r++}return!1},_getRowAndColumnCount(e){let t=0,n=0;const i=e.getElementsByTagName(\"tr\");for(let e=0;e<i.length;e++){let r=i[e].getAttribute(\"rowspan\")||0;r&&(r=parseInt(r,10)),t+=r||1;let s=0;const a=i[e].getElementsByTagName(\"td\");for(let e=0;e<a.length;e++){let t=a[e].getAttribute(\"colspan\")||0;t&&(t=parseInt(t,10)),s+=t||1}n=Math.max(n,s)}return{rows:t,columns:n}},_markDataTables(e){const t=e.getElementsByTagName(\"table\");for(let e=0;e<t.length;e++){var n=t[e];if(\"presentation\"==n.getAttribute(\"role\")){n._readabilityDataTable=!1;continue}if(\"0\"==n.getAttribute(\"datatable\")){n._readabilityDataTable=!1;continue}if(n.getAttribute(\"summary\")){n._readabilityDataTable=!0;continue}const i=n.getElementsByTagName(\"caption\")[0];if(i&&i.childNodes.length>0){n._readabilityDataTable=!0;continue}if([\"col\",\"colgroup\",\"tfoot\",\"thead\",\"th\"].some((function(e){return!!n.getElementsByTagName(e)[0]}))){this.log(\"Data table because found data-y descendant\"),n._readabilityDataTable=!0;continue}if(n.getElementsByTagName(\"table\")[0]){n._readabilityDataTable=!1;continue}const r=this._getRowAndColumnCount(n);r.rows>=10||r.columns>4?n._readabilityDataTable=!0:n._readabilityDataTable=r.rows*r.columns>10}},_fixLazyImages(e){this._forEachNode(this._getAllNodesWithTag(e,[\"img\",\"picture\",\"figure\"]),(function(e){if(e.src&&this.REGEXPS.b64DataUrl.test(e.src)){if(\"image/svg+xml\"===this.REGEXPS.b64DataUrl.exec(e.src)[1])return;let n=!1;for(let i=0;i<e.attributes.length;i++){var t=e.attributes[i];if(\"src\"!==t.name&&/\.(jpg|jpeg|png|webp)/i.test(t.value)){n=!0;break}}if(n){const t=e.src.search(/base64\s*/i)+7;e.src.length-t<133&&e.removeAttribute(\"src\")}}if(!(e.src||e.srcset&&\"null\"!=e.srcset)||-1!==e.className.toLowerCase().indexOf(\"lazy\"))for(let n=0;n<e.attributes.length;n++){if(\"src\"===(t=e.attributes[n]).name||\"srcset\"===t.name)continue;let i=null;if(/\.(jpg|jpeg|png|webp)\s+\d/.test(t.value)?i=\"srcset\":/^\s*\S+\.(jpg|jpeg|png|webp)\S*\s*$/.test(t.value)&&(i=\"src\"),i)if(\"IMG\"===e.tagName||\"PICTURE\"===e.tagName)e.setAttribute(i,t.value);else if(\"FIGURE\"===e.tagName&&!this._getAllNodesWithTag(e,[\"img\",\"picture\"]).length){const n=this._doc.createElement(\"img\");n.setAttribute(i,t.value),e.appendChild(n)}}}))},_cleanConditionally(e,t){if(!this._flagIsActive(this.FLAG_CLEAN_CONDITIONALLY))return;const n=\"ul\"===t||\"ol\"===t;this._removeNodes(this._getAllNodesWithTag(e,[t]),(function(e){const i=function(e){return e._readabilityDataTable};if(\"table\"===t&&i(e))return!1;if(this._hasAncestorTag(e,\"table\",-1,i))return!1;const r=this._getClassWeight(e);if(this.log(\"Cleaning Conditionally\",e),r+0<0)return!0;if(this._getCharCount(e,\",\")<10){const t=e.getElementsByTagName(\"p\").length,i=e.getElementsByTagName(\"img\").length,s=e.getElementsByTagName(\"li\").length-100,a=e.getElementsByTagName(\"input\").length;let o=0;const l=this._getAllNodesWithTag(e,[\"object\",\"embed\",\"iframe\"]);for(let e=0;e<l.length;e++){for(let t=0;t<l[e].attributes.length;t++)if(this.REGEXPS.videos.test(l[e].attributes[t].value))return!1;if(\"object\"===l[e].tagName&&this.REGEXPS.videos.test(l[e].innerHTML))return!1;o++}const c=this._getLinkDensity(e),h=this._getInnerText(e).length;return i>1&&t/i<.5&&!this._hasAncestorTag(e,\"figure\")||!n&&s>t||a>Math.floor(t/3)||!n&&h<25&&(0===i||i>2)&&!this._hasAncestorTag(e,\"figure\")||!n&&r<25&&c>.2||r>=25&&c>.5||1===o&&h<75||o>1}return!1}))},_cleanMatchedNodes(e,t){const n=this._getNextNode(e,!0);let i=this._getNextNode(e);for(;i&&i!=n;)i=t.call(this,i,i.className+\" \"+i.id)?this._removeAndGetNext(i):this._getNextNode(i)},_cleanHeaders(e){this._removeNodes(this._getAllNodesWithTag(e,[\"h1\",\"h2\"]),(function(e){return this._getClassWeight(e)<0}))},_flagIsActive(e){return(this._flags&e)>0},_removeFlag(e){this._flags=this._flags&~e},_isProbablyVisible:e=>(!e.style||\"none\"!=e.style.display)&&!e.hasAttribute(\"hidden\")&&(!e.hasAttribute(\"aria-hidden\")||\"true\"!=e.getAttribute(\"aria-hidden\")||e.className&&e.className.indexOf&&-1!==e.className.indexOf(\"fallback-image\")),parse(){if(this._maxElemsToParse>0){const e=this._doc.getElementsByTagName(\"*\").length;if(e>this._maxElemsToParse)throw new Error(\"Aborting parsing document; \"+e+\" elements found\")}this._unwrapNoscriptImages(this._doc),this._removeScripts(this._doc),this._prepDocument();const e=this._getArticleMetadata();this._articleTitle=e.title;const t=this._grabArticle();if(!t)return null;if(this.log(\"Grabbed: \"+t.innerHTML),this._postProcessContent(t),!e.excerpt){const n=t.getElementsByTagName(\"p\");n.length>0&&(e.excerpt=n[0].textContent.trim())}const n=t.textContent;return{title:this._articleTitle,byline:e.byline||this._articleByline,dir:this._articleDir,content:t.innerHTML,textContent:n,length:n.length,excerpt:e.excerpt,siteName:e.siteName||this._articleSiteName}}};const blockElements=[\"address\",\"article\",\"aside\",\"audio\",\"blockquote\",\"body\",\"canvas\",\"center\",\"dd\",\"dir\",\"div\",\"dl\",\"dt\",\"fieldset\",\"figcaption\",\"figure\",\"footer\",\"form\",\"frameset\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"header\",\"hgroup\",\"hr\",\"html\",\"isindex\",\"li\",\"main\",\"menu\",\"nav\",\"noframes\",\"noscript\",\"ol\",\"output\",\"p\",\"pre\",\"section\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"tr\",\"ul\"];function isBlock(e){return-1!==blockElements.indexOf(e.nodeName.toLowerCase())}const voidElements=[\"area\",\"base\",\"br\",\"col\",\"command\",\"embed\",\"hr\",\"img\",\"input\",\"keygen\",\"link\",\"meta\",\"param\",\"source\",\"track\",\"wbr\"];function isVoid(e){return-1!==voidElements.indexOf(e.nodeName.toLowerCase())}const voidSelector=voidElements.join();function hasVoid(e){return e.querySelector&&e.querySelector(voidSelector)}const rules={};function Rules(e){this.options=e,this._keep=[],this._remove=[],this.blankRule={replacement:e.blankReplacement},this.keepReplacement=e.keepReplacement,this.defaultRule={replacement:e.defaultReplacement},this.array=[];for(const t in e.rules)this.array.push(e.rules[t])}function findRule(e,t,n){for(let i=0;i<e.length;i++){const r=e[i];if(filterValue(r,t,n))return r}}function filterValue(e,t,n){const i=e.filter;if(\"string\"==typeof i){if(i===t.nodeName.toLowerCase())return!0}else if(Array.isArray(i)){if(i.indexOf(t.nodeName.toLowerCase())>-1)return!0}else{if(\"function\"!=typeof i)throw new TypeError(\"`filter` needs to be a string, array, or function\");if(i.call(e,t,n))return!0}}function collapseWhitespace(e){const t=e.element,n=e.isBlock,i=e.isVoid,r=e.isPre||function(e){return\"PRE\"===e.nodeName};if(!t.firstChild||r(t))return;let s=null,a=!1,o=null,l=next(o,t,r);for(;l!==t;){if(3===l.nodeType||4===l.nodeType){let e=l.data.replace(/[ \r\n\t]+/g,\" \");if(s&&!/ $/.test(s.data)||a||\" \"!==e[0]||(e=e.substr(1)),!e){l=remove(l);continue}l.data=e,s=l}else{if(1!==l.nodeType){l=remove(l);continue}n(l)||\"BR\"===l.nodeName?(s&&(s.data=s.data.replace(/ $/,\"\")),s=null,a=!1):i(l)&&(s=null,a=!0)}const e=next(o,l,r);o=l,l=e}s&&(s.data=s.data.replace(/ $/,\"\"),s.data||remove(s))}function remove(e){const t=e.nextSibling||e.parentNode;return e.parentNode.removeChild(e),t}function next(e,t,n){return e&&e.parentNode===t||n(t)?t.nextSibling||t.parentNode:t.firstChild||t.nextSibling||t.parentNode}rules.paragraph={filter:\"p\",replacement:function(e){return\"\n\n\"+e+\"\n\n\"}},rules.lineBreak={filter:\"br\",replacement:function(e,t,n){return n.br+\"\n\"}},rules.heading={filter:[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"],replacement:function(e,t,n){const i=Number(t.nodeName.charAt(1));if(\"setext\"===n.headingStyle&&i<3){return\"\n\n\"+e+\"\n\"+repeat(1===i?\"=\":\"-\",e.length)+\"\n\n\"}return\"\n\n\"+repeat(\"#\",i)+\" \"+e+\"\n\n\"}},rules.blockquote={filter:\"blockquote\",replacement:function(e){return\"\n\n\"+(e=(e=e.replace(/^\n+|\n+$/g,\"\")).replace(/^/gm,\"> \"))+\"\n\n\"}},rules.list={filter:[\"ul\",\"ol\"],replacement:function(e,t){const n=t.parentNode;return\"LI\"===n.nodeName&&n.lastElementChild===t?\"\n\"+e:\"\n\n\"+e+\"\n\n\"}},rules.listItem={filter:\"li\",replacement:function(e,t,n){e=e.replace(/^\n+/,\"\").replace(/\n+$/,\"\n\").replace(/\n/gm,\"\n \");let i=n.bulletListMarker+\" \";const r=t.parentNode;if(\"OL\"===r.nodeName){const e=r.getAttribute(\"start\"),n=Array.prototype.indexOf.call(r.children,t);i=(e?Number(e)+n:n+1)+\". \"}return i+e+(t.nextSibling&&!/\n$/.test(e)?\"\n\":\"\")}},rules.indentedCodeBlock={filter:function(e,t){return\"indented\"===t.codeBlockStyle&&\"PRE\"===e.nodeName&&e.firstChild&&\"CODE\"===e.firstChild.nodeName},replacement:function(e,t,n){return\"\n\n \"+t.firstChild.textContent.replace(/\n/g,\"\n \")+\"\n\n\"}},rules.fencedCodeBlock={filter:function(e,t){return\"fenced\"===t.codeBlockStyle&&\"PRE\"===e.nodeName&&e.firstChild&&\"CODE\"===e.firstChild.nodeName},replacement:function(e,t,n){const i=((t.firstChild.className||\"\").match(/language-(\S+)/)||[null,\"\"])[1],r=t.firstChild.textContent,s=n.fence.charAt(0);let a=3;const o=new RegExp(\"^\"+s+\"{3,}\",\"gm\");let l;for(;l=o.exec(r);)l[0].length>=a&&(a=l[0].length+1);const c=repeat(s,a);return\"\n\n\"+c+i+\"\n\"+r.replace(/\n$/,\"\")+\"\n\"+c+\"\n\n\"}},rules.horizontalRule={filter:\"hr\",replacement:function(e,t,n){return\"\n\n\"+n.hr+\"\n\n\"}},rules.inlineLink={filter:function(e,t){return\"inlined\"===t.linkStyle&&\"A\"===e.nodeName&&e.getAttribute(\"href\")},replacement:function(e,t){return\"[\"+e+\"](\"+t.getAttribute(\"href\")+(t.title?' \"'+t.title+'\"':\"\")+\")\"}},rules.referenceLink={filter:function(e,t){return\"referenced\"===t.linkStyle&&\"A\"===e.nodeName&&e.getAttribute(\"href\")},replacement:function(e,t,n){const i=t.getAttribute(\"href\"),r=t.title?' \"'+t.title+'\"':\"\";let s,a;switch(n.linkReferenceStyle){case\"collapsed\":s=\"[\"+e+\"][]\",a=\"[\"+e+\"]: \"+i+r;break;case\"shortcut\":s=\"[\"+e+\"]\",a=\"[\"+e+\"]: \"+i+r;break;default:var o=this.references.length+1;s=\"[\"+e+\"][\"+o+\"]\",a=\"[\"+o+\"]: \"+i+r}return this.references.push(a),s},references:[],append:function(e){let t=\"\";return this.references.length&&(t=\"\n\n\"+this.references.join(\"\n\")+\"\n\n\",this.references=[]),t}},rules.emphasis={filter:[\"em\",\"i\"],replacement:function(e,t,n){return e.trim()?n.emDelimiter+e+n.emDelimiter:\"\"}},rules.strong={filter:[\"strong\",\"b\"],replacement:function(e,t,n){return e.trim()?n.strongDelimiter+e+n.strongDelimiter:\"\"}},rules.code={filter:function(e){const t=e.previousSibling||e.nextSibling,n=\"PRE\"===e.parentNode.nodeName&&!t;return\"CODE\"===e.nodeName&&!n},replacement:function(e){if(!e.trim())return\"\";let t=\"`\",n=\"\",i=\"\";const r=e.match(/`+/gm);if(r)for(/^`/.test(e)&&(n=\" \"),/`$/.test(e)&&(i=\" \");-1!==r.indexOf(t);)t+=\"`\";return t+n+e+i+t}},rules.image={filter:\"img\",replacement:function(e,t){const n=t.alt||\"\",i=t.getAttribute(\"src\")||\"\",r=t.title||\"\";return i?\"![\"+n+\"](\"+i+(r?' \"'+r+'\"':\"\")+\")\":\"\"}},Rules.prototype={add:function(e,t){this.array.unshift(t)},keep:function(e){this._keep.unshift({filter:e,replacement:this.keepReplacement})},remove:function(e){this._remove.unshift({filter:e,replacement:function(){return\"\"}})},forNode:function(e){if(e.isBlank)return this.blankRule;let t;return(t=findRule(this.array,e,this.options))||(t=findRule(this._keep,e,this.options))||(t=findRule(this._remove,e,this.options))?t:this.defaultRule},forEach:function(e){for(let t=0;t<this.array.length;t++)e(this.array[t],t)}};const root=\"undefined\"!=typeof window?window:{};function canParseHTMLNatively(){const e=root.DOMParser;let t=!1;try{(new e).parseFromString(\"\",\"text/html\")&&(t=!0)}catch(e){}return t}function createHTMLParser(){const e=function(){};{const t=require(\"jsdom\").JSDOM;e.prototype.parseFromString=function(e){return new t(e).window.document}}return e}const HTMLParser=canParseHTMLNatively()?root.DOMParser:createHTMLParser();function RootNode(e){let t;if(\"string\"==typeof e){t=htmlParser().parseFromString('<x-turndown id=\"turndown-root\">'+e+\"</x-turndown>\",\"text/html\").getElementById(\"turndown-root\")}else t=e.cloneNode(!0);return collapseWhitespace({element:t,isBlock:isBlock,isVoid:isVoid}),t}let _htmlParser;function htmlParser(){return _htmlParser=_htmlParser||new HTMLParser,_htmlParser}function Node(e){return e.isBlock=isBlock(e),e.isCode=\"code\"===e.nodeName.toLowerCase()||e.parentNode.isCode,e.isBlank=isBlank(e),e.flankingWhitespace=flankingWhitespace(e),e}function isBlank(e){return-1===[\"A\",\"TH\",\"TD\",\"IFRAME\",\"SCRIPT\",\"AUDIO\",\"VIDEO\"].indexOf(e.nodeName)&&/^\s*$/i.test(e.textContent)&&!isVoid(e)&&!hasVoid(e)}function flankingWhitespace(e){let t=\"\",n=\"\";if(!e.isBlock){const i=/^\s/.test(e.textContent),r=/\s$/.test(e.textContent),s=e.isBlank&&i&&r;i&&!isFlankedByWhitespace(\"left\",e)&&(t=\" \"),s||!r||isFlankedByWhitespace(\"right\",e)||(n=\" \")}return{leading:t,trailing:n}}function isFlankedByWhitespace(e,t){let n,i,r;return\"left\"===e?(n=t.previousSibling,i=/ $/):(n=t.nextSibling,i=/^ /),n&&(3===n.nodeType?r=i.test(n.nodeValue):1!==n.nodeType||isBlock(n)||(r=i.test(n.textContent))),r}const reduce=Array.prototype.reduce,leadingNewLinesRegExp=/^\n*/,trailingNewLinesRegExp=/\n*$/,escapes=[[/\\/g,\"\\\\\"],[/\*/g,\"\\*\"],[/^-/g,\"\\-\"],[/^\+ /g,\"\\+ \"],[/^(=+)/g,\"\\$1\"],[/^(#{1,6}) /g,\"\\$1 \"],[/`/g,\"\\`\"],[/^~~~/g,\"\\~~~\"],[/\[/g,\"\\[\"],[/\]/g,\"\\]\"],[/^>/g,\"\\>\"],[/_/g,\"\\_\"],[/^(\d+)\. /g,\"$1\\. \"]];function TurndownService(e){if(!(this instanceof TurndownService))return new TurndownService(e);const t={rules:rules,headingStyle:\"setext\",hr:\"* * *\",bulletListMarker:\"*\",codeBlockStyle:\"indented\",fence:\"```\",emDelimiter:\"_\",strongDelimiter:\"**\",linkStyle:\"inlined\",linkReferenceStyle:\"full\",br:\" \",blankReplacement:function(e,t){return t.isBlock?\"\n\n\":\"\"},keepReplacement:function(e,t){return t.isBlock?\"\n\n\"+t.outerHTML+\"\n\n\":t.outerHTML},defaultReplacement:function(e,t){return t.isBlock?\"\n\n\"+e+\"\n\n\":e}};this.options=extend({},t,e),this.rules=new Rules(this.options)}function process(e){const t=this;return reduce.call(e.childNodes,(function(e,n){let i=\"\";return 3===(n=new Node(n)).nodeType?i=n.isCode?n.nodeValue:t.escape(n.nodeValue):1===n.nodeType&&(i=replacementForNode.call(t,n)),join(e,i)}),\"\")}function postProcess(e){const t=this;return this.rules.forEach((function(n){\"function\"==typeof n.append&&(e=join(e,n.append(t.options)))})),e.replace(/^[\t\r\n]+/,\"\").replace(/[\t\r\n\s]+$/,\"\")}function replacementForNode(e){const t=this.rules.forNode(e);let n=process.call(this,e);const i=e.flankingWhitespace;return(i.leading||i.trailing)&&(n=n.trim()),i.leading+t.replacement(n,e,this.options)+i.trailing}function separatingNewlines(e,t){const n=[e.match(trailingNewLinesRegExp)[0],t.match(leadingNewLinesRegExp)[0]].sort(),i=n[n.length-1];return i.length<2?i:\"\n\n\"}function join(e,t){const n=separatingNewlines(e,t);return(e=e.replace(trailingNewLinesRegExp,\"\"))+n+(t=t.replace(leadingNewLinesRegExp,\"\"))}function canConvert(e){return null!=e&&(\"string\"==typeof e||e.nodeType&&(1===e.nodeType||9===e.nodeType||11===e.nodeType))}if(TurndownService.prototype={turndown:function(e){if(!canConvert(e))throw new TypeError(e+\" is not a string, or an element/document/fragment node.\");if(\"\"===e)return\"\";const t=process.call(this,new RootNode(e));return postProcess.call(this,t)},use:function(e){if(Array.isArray(e))for(let t=0;t<e.length;t++)this.use(e[t]);else{if(\"function\"!=typeof e)throw new TypeError(\"plugin must be a Function or an Array of Functions\");e(this)}return this},addRule:function(e,t){return this.rules.add(e,t),this},keep:function(e){return this.rules.keep(e),this},remove:function(e){return this.rules.remove(e),this},escape:function(e){return escapes.reduce((function(e,t){return e.replace(t[0],t[1])}),e)}},document.querySelector('meta[name=\"keywords\" i]')){document.querySelector('meta[name=\"keywords\" i]').getAttribute(\"content\").split(\",\").forEach((function(e){const t=\" \"+e.split(\" \").join(\"\");tags+=t}))}function getSelectionHtml(){let e=\"\";if(void 0!==window.getSelection){const t=window.getSelection();if(t.rangeCount){const n=document.createElement(\"div\");for(let e=0,i=t.rangeCount;e<i;++e)n.appendChild(t.getRangeAt(e).cloneContents());e=n.innerHTML}}else void 0!==document.selection&&\"Text\"==document.selection.type&&(e=document.selection.createRange().htmlText);return e}const selection=getSelectionHtml(),{title:title,byline:byline,content:content}=new Readability(document.cloneNode(!0)).parse();function getFileName(e){window.navigator.userAgent;const t=window.navigator.platform;return e=-1!==[\"Win32\",\"Win64\",\"Windows\",\"WinCE\"].indexOf(t)?e.replace(\":\",\"\").replace(/[/\\?%*|\"<>]/g,\"-\"):e.replace(\":\",\"\").replace(/\//g,\"-\").replace(/\\/g,\"-\")}const fileName=getFileName(title);if(selection)var markdownify=selection;else markdownify=content;var vaultName=\"\";const markdownBody=new TurndownService({headingStyle:\"atx\",hr:\"---\",bulletListMarker:\"-\",codeBlockStyle:\"fenced\",emDelimiter:\"*\"}).turndown(markdownify);function convertDate(e){const t=e.getFullYear().toString(),n=(e.getMonth()+1).toString(),i=e.getDate().toString(),r=n.split(\"\"),s=i.split(\"\");return t+\"-\"+(r[1]?n:\"0\"+r[0])+\"-\"+(s[1]?i:\"0\"+s[0])}const today=convertDate(date=new Date);function getMetaContent(e,t){const n=document.querySelector(`meta[${e}='${t}']`);return n?n.getAttribute(\"content\").trim():\"\"}const author=byline||getMetaContent(\"name\",\"author\")||getMetaContent(\"property\",\"author\")||getMetaContent(\"property\",\"og:site_name\"),authorBrackets=author?`\"[[${author}]]\"`:\"\",timeElement=document.querySelector(\"time\"),publishedDate=timeElement?timeElement.getAttribute(\"datetime\"):\"\";if(publishedDate&&\"\"!==publishedDate.trim()){var date;const e=(date=new Date(publishedDate)).getFullYear();let t=date.getMonth()+1,n=date.getDate();t=t<10?\"0\"+t:t,n=n<10?\"0\"+n:n;var published=e+\"-\"+t+\"-\"+n}else published=\"\";const fileContent=\"Author: \"+author+'\nTitle: \"'+title+'\"\nSource: '+document.URL+\"\nClip Date: \"+today+\"\nPublished: \"+published+\"\nTopics: \nTags: \"+tags+\"\n\n<br><h1>\"+title+\"</h1>\"+markdownBody;\n\ncompletion(fileContent)")
	@Clip
} else {
	// Shortcut input is clipboard from bookmarklet

	getClipboard()
	@Clip
}
const SplitText = splitText(@Clip, "/n/n")

for _ in SplitText {
}
joinText(RepeatResults, "&#12;")
@Content
// If pass of Clip variable has no value, either split text failed, or content has encoding that is not parsable or CSP is enforced. Use Clip directly and accept formatting as is. 


if !@Content {
	@Content = @Clip
} else {
}
// Notes renders level 3 headers as bold and not subheadings. Replace with level 2. 

replaceText("### ", "## ", @Content)
@Content
const ReadabilityPageContent = getRichTextFromMarkdown(@Content)
currentDate()
formatDate(, "Custom", "EEE d MMM YYYY 'at' HH:mm:ss  zzz")
const Text = "<br>\n<h2>Clip to Notes : {} ≫</h2>"
const ClipHeader = getRichTextFromHTML(Text)
const List = list(ClipHeader, ReadabilityPageContent)
joinText(List, "
")
const AppendedNote = appendNote("", List)
/*
Best to run this shortcut from the share sheet or using the bookmarklet, using Safari and Notes in split view, or Notes in Slide over. 

If shortcut input is 0 then Clip to Notes was invoked from the bookmarklet. Open the Note so we dont end up in the Shortcuts app 
*/

if Count == 0 {
	openNote(AppendedNote)
} else {
}
output("")
Mit cherri 2.3.0 (GPL-2.0) dekompiliert. Eventuell sind kleine Korrekturen nötig, bevor es kompiliert wird.

Bewertungen und Rezensionen

Rezension schreiben
–
von 5
★★★★★
★★★★
★★★
★★
★
0 ratings

No reviews yet. Be the first to share what you think!

Werbung

Das gefällt dir vielleicht auch

Alle anzeigen
Werbung