├── .eslintrc.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── keymaps └── web-clipper.json ├── lib ├── Readability.js ├── web-clipper-message-dialog.js └── web-clipper.js ├── menus └── web-clipper.json ├── package-lock.json └── package.json /.eslintrc.yml: -------------------------------------------------------------------------------- 1 | root: true 2 | plugins: 3 | - react 4 | - prettier 5 | extends: 6 | - plugin:react/recommended 7 | - plugin:prettier/recommended 8 | parser: babel-eslint 9 | env: {} 10 | globals: 11 | inkdrop: readonly 12 | rules: 13 | no-useless-escape: 0 14 | prettier/prettier: 15 | - 2 16 | - 17 | trailingComma: none 18 | singleQuote: true 19 | semi: false 20 | prefer-const: 2 21 | no-unused-vars: 22 | - 2 23 | - 24 | argsIgnorePattern: ^_ 25 | varsIgnorePattern: ^_ 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | .vscode/settings.json 5 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 - First Release 2 | * Every feature added 3 | * Every bug fixed 4 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 James Sartelle 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Inkdrop Web Clipper 2 | 3 | A plugin for [Inkdrop](https://www.inkdrop.info/) which allows you to clip web pages into new notes, similar to Evernote or OneNote. 4 | 5 | 6 | It uses [Readability.js](https://github.com/mozilla/readability/) to extract the article content, and converts it into Markdown automatically. 7 | 8 | ## Usage 9 | 10 | Select `Plugins` > `Clip Web Page...` from the menu bar, or press (default) `Ctrl+Alt+C`. 11 | 12 | ## Acknowledgement 13 | 14 | This is a fork from charygao web-clipper version. 15 | It has been modified to work with inkdrop 4 and more features have been added. -------------------------------------------------------------------------------- /keymaps/web-clipper.json: -------------------------------------------------------------------------------- 1 | { 2 | "body": { 3 | "ctrl-alt-c": "web-clipper:clip-page" 4 | } 5 | } -------------------------------------------------------------------------------- /lib/Readability.js: -------------------------------------------------------------------------------- 1 | /*eslint-env es6:false*/ 2 | /* 3 | * Copyright (c) 2010 Arc90 Inc 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /* 19 | * This code is heavily based on Arc90's readability.js (1.7.1) script 20 | * available at: http://code.google.com/p/arc90labs-readability 21 | */ 22 | 23 | /** 24 | * Public constructor. 25 | * @param {HTMLDocument} doc The document to parse. 26 | * @param {Object} options The options object. 27 | */ 28 | function Readability(doc, options) { 29 | // In some older versions, people passed a URI as the first argument. Cope: 30 | if (options && options.documentElement) { 31 | doc = options; 32 | options = arguments[2]; 33 | } else if (!doc || !doc.documentElement) { 34 | throw new Error("First argument to Readability constructor should be a document object."); 35 | } 36 | options = options || {}; 37 | 38 | this._doc = doc; 39 | this._articleTitle = null; 40 | this._articleByline = null; 41 | this._articleDir = null; 42 | this._articleSiteName = null; 43 | this._attempts = []; 44 | 45 | // Configurable options 46 | this._debug = !!options.debug; 47 | this._maxElemsToParse = options.maxElemsToParse || this.DEFAULT_MAX_ELEMS_TO_PARSE; 48 | this._nbTopCandidates = options.nbTopCandidates || this.DEFAULT_N_TOP_CANDIDATES; 49 | this._charThreshold = options.charThreshold || this.DEFAULT_CHAR_THRESHOLD; 50 | this._classesToPreserve = this.CLASSES_TO_PRESERVE.concat(options.classesToPreserve || []); 51 | this._keepClasses = !!options.keepClasses; 52 | 53 | // Start with all flags set 54 | this._flags = this.FLAG_STRIP_UNLIKELYS | 55 | this.FLAG_WEIGHT_CLASSES | 56 | this.FLAG_CLEAN_CONDITIONALLY; 57 | 58 | var logEl; 59 | 60 | // Control whether log messages are sent to the console 61 | if (this._debug) { 62 | logEl = function(e) { 63 | var rv = e.nodeName + " "; 64 | if (e.nodeType == e.TEXT_NODE) { 65 | return rv + '("' + e.textContent + '")'; 66 | } 67 | var classDesc = e.className && ("." + e.className.replace(/ /g, ".")); 68 | var elDesc = ""; 69 | if (e.id) 70 | elDesc = "(#" + e.id + classDesc + ")"; 71 | else if (classDesc) 72 | elDesc = "(" + classDesc + ")"; 73 | return rv + elDesc; 74 | }; 75 | this.log = function () { 76 | if (typeof dump !== "undefined") { 77 | var msg = Array.prototype.map.call(arguments, function(x) { 78 | return (x && x.nodeName) ? logEl(x) : x; 79 | }).join(" "); 80 | dump("Reader: (Readability) " + msg + "\n"); 81 | } else if (typeof console !== "undefined") { 82 | var args = ["Reader: (Readability) "].concat(arguments); 83 | console.log.apply(console, args); 84 | } 85 | }; 86 | } else { 87 | this.log = function () {}; 88 | } 89 | } 90 | 91 | Readability.prototype = { 92 | FLAG_STRIP_UNLIKELYS: 0x1, 93 | FLAG_WEIGHT_CLASSES: 0x2, 94 | FLAG_CLEAN_CONDITIONALLY: 0x4, 95 | 96 | // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType 97 | ELEMENT_NODE: 1, 98 | TEXT_NODE: 3, 99 | 100 | // Max number of nodes supported by this parser. Default: 0 (no limit) 101 | DEFAULT_MAX_ELEMS_TO_PARSE: 0, 102 | 103 | // The number of top candidates to consider when analysing how 104 | // tight the competition is among candidates. 105 | DEFAULT_N_TOP_CANDIDATES: 5, 106 | 107 | // Element tags to score by default. 108 | DEFAULT_TAGS_TO_SCORE: "section,h2,h3,h4,h5,h6,p,td,pre".toUpperCase().split(","), 109 | 110 | // The default number of chars an article must have in order to return a result 111 | DEFAULT_CHAR_THRESHOLD: 500, 112 | 113 | // All of the regular expressions in use within readability. 114 | // Defined up here so we don't instantiate them repeatedly in loops. 115 | REGEXPS: { 116 | // NOTE: These two regular expressions are duplicated in 117 | // Readability-readerable.js. Please keep both copies in sync. 118 | 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, 119 | okMaybeItsACandidate: /and|article|body|column|content|main|shadow/i, 120 | 121 | positive: /article|body|content|entry|hentry|h-entry|main|page|pagination|post|text|blog|story/i, 122 | 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, 123 | extraneous: /print|archive|comment|discuss|e[\-]?mail|share|reply|all|login|sign|single|utility/i, 124 | byline: /byline|author|dateline|writtenby|p-author/i, 125 | replaceFonts: /<(\/?)font[^>]*>/gi, 126 | normalize: /\s{2,}/g, 127 | videos: /\/\/(www\.)?((dailymotion|youtube|youtube-nocookie|player\.vimeo|v\.qq)\.com|(archive|upload\.wikimedia)\.org|player\.twitch\.tv)/i, 128 | shareElements: /(\b|_)(share|sharedaddy)(\b|_)/i, 129 | nextLink: /(next|weiter|continue|>([^\|]|$)|»([^\|]|$))/i, 130 | prevLink: /(prev|earl|old|new|<|«)/i, 131 | whitespace: /^\s*$/, 132 | hasContent: /\S$/, 133 | }, 134 | 135 | DIV_TO_P_ELEMS: [ "A", "BLOCKQUOTE", "DL", "DIV", "IMG", "OL", "P", "PRE", "TABLE", "UL", "SELECT" ], 136 | 137 | ALTER_TO_DIV_EXCEPTIONS: ["DIV", "ARTICLE", "SECTION", "P"], 138 | 139 | PRESENTATIONAL_ATTRIBUTES: [ "align", "background", "bgcolor", "border", "cellpadding", "cellspacing", "frame", "hspace", "rules", "style", "valign", "vspace" ], 140 | 141 | DEPRECATED_SIZE_ATTRIBUTE_ELEMS: [ "TABLE", "TH", "TD", "HR", "PRE" ], 142 | 143 | // The commented out elements qualify as phrasing content but tend to be 144 | // removed by readability when put into paragraphs, so we ignore them here. 145 | PHRASING_ELEMS: [ 146 | // "CANVAS", "IFRAME", "SVG", "VIDEO", 147 | "ABBR", "AUDIO", "B", "BDO", "BR", "BUTTON", "CITE", "CODE", "DATA", 148 | "DATALIST", "DFN", "EM", "EMBED", "I", "IMG", "INPUT", "KBD", "LABEL", 149 | "MARK", "MATH", "METER", "NOSCRIPT", "OBJECT", "OUTPUT", "PROGRESS", "Q", 150 | "RUBY", "SAMP", "SCRIPT", "SELECT", "SMALL", "SPAN", "STRONG", "SUB", 151 | "SUP", "TEXTAREA", "TIME", "VAR", "WBR" 152 | ], 153 | 154 | // These are the classes that readability sets itself. 155 | CLASSES_TO_PRESERVE: [ "page" ], 156 | 157 | /** 158 | * Run any post-process modifications to article content as necessary. 159 | * 160 | * @param Element 161 | * @return void 162 | **/ 163 | _postProcessContent: function(articleContent) { 164 | // Readability cannot open relative uris so we convert them to absolute uris. 165 | this._fixRelativeUris(articleContent); 166 | 167 | if (!this._keepClasses) { 168 | // Remove classes. 169 | this._cleanClasses(articleContent); 170 | } 171 | }, 172 | 173 | /** 174 | * Iterates over a NodeList, calls `filterFn` for each node and removes node 175 | * if function returned `true`. 176 | * 177 | * If function is not passed, removes all the nodes in node list. 178 | * 179 | * @param NodeList nodeList The nodes to operate on 180 | * @param Function filterFn the function to use as a filter 181 | * @return void 182 | */ 183 | _removeNodes: function(nodeList, filterFn) { 184 | for (var i = nodeList.length - 1; i >= 0; i--) { 185 | var node = nodeList[i]; 186 | var parentNode = node.parentNode; 187 | if (parentNode) { 188 | if (!filterFn || filterFn.call(this, node, i, nodeList)) { 189 | parentNode.removeChild(node); 190 | } 191 | } 192 | } 193 | }, 194 | 195 | /** 196 | * Iterates over a NodeList, and calls _setNodeTag for each node. 197 | * 198 | * @param NodeList nodeList The nodes to operate on 199 | * @param String newTagName the new tag name to use 200 | * @return void 201 | */ 202 | _replaceNodeTags: function(nodeList, newTagName) { 203 | for (var i = nodeList.length - 1; i >= 0; i--) { 204 | var node = nodeList[i]; 205 | this._setNodeTag(node, newTagName); 206 | } 207 | }, 208 | 209 | /** 210 | * Iterate over a NodeList, which doesn't natively fully implement the Array 211 | * interface. 212 | * 213 | * For convenience, the current object context is applied to the provided 214 | * iterate function. 215 | * 216 | * @param NodeList nodeList The NodeList. 217 | * @param Function fn The iterate function. 218 | * @return void 219 | */ 220 | _forEachNode: function(nodeList, fn) { 221 | Array.prototype.forEach.call(nodeList, fn, this); 222 | }, 223 | 224 | /** 225 | * Iterate over a NodeList, return true if any of the provided iterate 226 | * function calls returns true, false otherwise. 227 | * 228 | * For convenience, the current object context is applied to the 229 | * provided iterate function. 230 | * 231 | * @param NodeList nodeList The NodeList. 232 | * @param Function fn The iterate function. 233 | * @return Boolean 234 | */ 235 | _someNode: function(nodeList, fn) { 236 | return Array.prototype.some.call(nodeList, fn, this); 237 | }, 238 | 239 | /** 240 | * Iterate over a NodeList, return true if all of the provided iterate 241 | * function calls return true, false otherwise. 242 | * 243 | * For convenience, the current object context is applied to the 244 | * provided iterate function. 245 | * 246 | * @param NodeList nodeList The NodeList. 247 | * @param Function fn The iterate function. 248 | * @return Boolean 249 | */ 250 | _everyNode: function(nodeList, fn) { 251 | return Array.prototype.every.call(nodeList, fn, this); 252 | }, 253 | 254 | /** 255 | * Concat all nodelists passed as arguments. 256 | * 257 | * @return ...NodeList 258 | * @return Array 259 | */ 260 | _concatNodeLists: function() { 261 | var slice = Array.prototype.slice; 262 | var args = slice.call(arguments); 263 | var nodeLists = args.map(function(list) { 264 | return slice.call(list); 265 | }); 266 | return Array.prototype.concat.apply([], nodeLists); 267 | }, 268 | 269 | _getAllNodesWithTag: function(node, tagNames) { 270 | if (node.querySelectorAll) { 271 | return node.querySelectorAll(tagNames.join(",")); 272 | } 273 | return [].concat.apply([], tagNames.map(function(tag) { 274 | var collection = node.getElementsByTagName(tag); 275 | return Array.isArray(collection) ? collection : Array.from(collection); 276 | })); 277 | }, 278 | 279 | /** 280 | * Removes the class="" attribute from every element in the given 281 | * subtree, except those that match CLASSES_TO_PRESERVE and 282 | * the classesToPreserve array from the options object. 283 | * 284 | * @param Element 285 | * @return void 286 | */ 287 | _cleanClasses: function(node) { 288 | var classesToPreserve = this._classesToPreserve; 289 | var className = (node.getAttribute("class") || "") 290 | .split(/\s+/) 291 | .filter(function(cls) { 292 | return classesToPreserve.indexOf(cls) != -1; 293 | }) 294 | .join(" "); 295 | 296 | if (className) { 297 | node.setAttribute("class", className); 298 | } else { 299 | node.removeAttribute("class"); 300 | } 301 | 302 | for (node = node.firstElementChild; node; node = node.nextElementSibling) { 303 | this._cleanClasses(node); 304 | } 305 | }, 306 | 307 | /** 308 | * Converts each and uri in the given element to an absolute URI, 309 | * ignoring #ref URIs. 310 | * 311 | * @param Element 312 | * @return void 313 | */ 314 | _fixRelativeUris: function(articleContent) { 315 | var baseURI = this._doc.baseURI; 316 | var documentURI = this._doc.documentURI; 317 | function toAbsoluteURI(uri) { 318 | // Leave hash links alone if the base URI matches the document URI: 319 | if (baseURI == documentURI && uri.charAt(0) == "#") { 320 | return uri; 321 | } 322 | // Otherwise, resolve against base URI: 323 | try { 324 | return new URL(uri, baseURI).href; 325 | } catch (ex) { 326 | // Something went wrong, just return the original: 327 | } 328 | return uri; 329 | } 330 | 331 | var links = this._getAllNodesWithTag(articleContent, ["a"]); 332 | this._forEachNode(links, function(link) { 333 | var href = link.getAttribute("href"); 334 | if (href) { 335 | // Replace links with javascript: URIs with text content, since 336 | // they won't work after scripts have been removed from the page. 337 | if (href.indexOf("javascript:") === 0) { 338 | var text = this._doc.createTextNode(link.textContent); 339 | link.parentNode.replaceChild(text, link); 340 | } else { 341 | link.setAttribute("href", toAbsoluteURI(href)); 342 | } 343 | } 344 | }); 345 | 346 | var imgs = this._getAllNodesWithTag(articleContent, ["img"]); 347 | this._forEachNode(imgs, function(img) { 348 | var src = img.getAttribute("src"); 349 | if (src) { 350 | img.setAttribute("src", toAbsoluteURI(src)); 351 | } 352 | }); 353 | }, 354 | 355 | /** 356 | * Get the article title as an H1. 357 | * 358 | * @return void 359 | **/ 360 | _getArticleTitle: function() { 361 | var doc = this._doc; 362 | var curTitle = ""; 363 | var origTitle = ""; 364 | 365 | try { 366 | curTitle = origTitle = doc.title.trim(); 367 | 368 | // If they had an element with id "title" in their HTML 369 | if (typeof curTitle !== "string") 370 | curTitle = origTitle = this._getInnerText(doc.getElementsByTagName("title")[0]); 371 | } catch (e) {/* ignore exceptions setting the title. */} 372 | 373 | var titleHadHierarchicalSeparators = false; 374 | function wordCount(str) { 375 | return str.split(/\s+/).length; 376 | } 377 | 378 | // If there's a separator in the title, first remove the final part 379 | if ((/ [\|\-\\\/>»] /).test(curTitle)) { 380 | titleHadHierarchicalSeparators = / [\\\/>»] /.test(curTitle); 381 | curTitle = origTitle.replace(/(.*)[\|\-\\\/>»] .*/gi, "$1"); 382 | 383 | // If the resulting title is too short (3 words or fewer), remove 384 | // the first part instead: 385 | if (wordCount(curTitle) < 3) 386 | curTitle = origTitle.replace(/[^\|\-\\\/>»]*[\|\-\\\/>»](.*)/gi, "$1"); 387 | } else if (curTitle.indexOf(": ") !== -1) { 388 | // Check if we have an heading containing this exact string, so we 389 | // could assume it's the full title. 390 | var headings = this._concatNodeLists( 391 | doc.getElementsByTagName("h1"), 392 | doc.getElementsByTagName("h2") 393 | ); 394 | var trimmedTitle = curTitle.trim(); 395 | var match = this._someNode(headings, function(heading) { 396 | return heading.textContent.trim() === trimmedTitle; 397 | }); 398 | 399 | // If we don't, let's extract the title out of the original title string. 400 | if (!match) { 401 | curTitle = origTitle.substring(origTitle.lastIndexOf(":") + 1); 402 | 403 | // If the title is now too short, try the first colon instead: 404 | if (wordCount(curTitle) < 3) { 405 | curTitle = origTitle.substring(origTitle.indexOf(":") + 1); 406 | // But if we have too many words before the colon there's something weird 407 | // with the titles and the H tags so let's just use the original title instead 408 | } else if (wordCount(origTitle.substr(0, origTitle.indexOf(":"))) > 5) { 409 | curTitle = origTitle; 410 | } 411 | } 412 | } else if (curTitle.length > 150 || curTitle.length < 15) { 413 | var hOnes = doc.getElementsByTagName("h1"); 414 | 415 | if (hOnes.length === 1) 416 | curTitle = this._getInnerText(hOnes[0]); 417 | } 418 | 419 | curTitle = curTitle.trim().replace(this.REGEXPS.normalize, " "); 420 | // If we now have 4 words or fewer as our title, and either no 421 | // 'hierarchical' separators (\, /, > or ») were found in the original 422 | // title or we decreased the number of words by more than 1 word, use 423 | // the original title. 424 | var curTitleWordCount = wordCount(curTitle); 425 | if (curTitleWordCount <= 4 && 426 | (!titleHadHierarchicalSeparators || 427 | curTitleWordCount != wordCount(origTitle.replace(/[\|\-\\\/>»]+/g, "")) - 1)) { 428 | curTitle = origTitle; 429 | } 430 | 431 | return curTitle; 432 | }, 433 | 434 | /** 435 | * Prepare the HTML document for readability to scrape it. 436 | * This includes things like stripping javascript, CSS, and handling terrible markup. 437 | * 438 | * @return void 439 | **/ 440 | _prepDocument: function() { 441 | var doc = this._doc; 442 | 443 | // Remove all style tags in head 444 | this._removeNodes(doc.getElementsByTagName("style")); 445 | 446 | if (doc.body) { 447 | this._replaceBrs(doc.body); 448 | } 449 | 450 | this._replaceNodeTags(doc.getElementsByTagName("font"), "SPAN"); 451 | }, 452 | 453 | /** 454 | * Finds the next element, starting from the given node, and ignoring 455 | * whitespace in between. If the given node is an element, the same node is 456 | * returned. 457 | */ 458 | _nextElement: function (node) { 459 | var next = node; 460 | while (next 461 | && (next.nodeType != this.ELEMENT_NODE) 462 | && this.REGEXPS.whitespace.test(next.textContent)) { 463 | next = next.nextSibling; 464 | } 465 | return next; 466 | }, 467 | 468 | /** 469 | * Replaces 2 or more successive
elements with a single

. 470 | * Whitespace between
elements are ignored. For example: 471 | *

foo
bar


abc
472 | * will become: 473 | *
foo
bar

abc

474 | */ 475 | _replaceBrs: function (elem) { 476 | this._forEachNode(this._getAllNodesWithTag(elem, ["br"]), function(br) { 477 | var next = br.nextSibling; 478 | 479 | // Whether 2 or more
elements have been found and replaced with a 480 | //

block. 481 | var replaced = false; 482 | 483 | // If we find a
chain, remove the
s until we hit another element 484 | // or non-whitespace. This leaves behind the first
in the chain 485 | // (which will be replaced with a

later). 486 | while ((next = this._nextElement(next)) && (next.tagName == "BR")) { 487 | replaced = true; 488 | var brSibling = next.nextSibling; 489 | next.parentNode.removeChild(next); 490 | next = brSibling; 491 | } 492 | 493 | // If we removed a
chain, replace the remaining
with a

. Add 494 | // all sibling nodes as children of the

until we hit another
495 | // chain. 496 | if (replaced) { 497 | var p = this._doc.createElement("p"); 498 | br.parentNode.replaceChild(p, br); 499 | 500 | next = p.nextSibling; 501 | while (next) { 502 | // If we've hit another

, we're done adding children to this

. 503 | if (next.tagName == "BR") { 504 | var nextElem = this._nextElement(next.nextSibling); 505 | if (nextElem && nextElem.tagName == "BR") 506 | break; 507 | } 508 | 509 | if (!this._isPhrasingContent(next)) 510 | break; 511 | 512 | // Otherwise, make this node a child of the new

. 513 | var sibling = next.nextSibling; 514 | p.appendChild(next); 515 | next = sibling; 516 | } 517 | 518 | while (p.lastChild && this._isWhitespace(p.lastChild)) { 519 | p.removeChild(p.lastChild); 520 | } 521 | 522 | if (p.parentNode.tagName === "P") 523 | this._setNodeTag(p.parentNode, "DIV"); 524 | } 525 | }); 526 | }, 527 | 528 | _setNodeTag: function (node, tag) { 529 | this.log("_setNodeTag", node, tag); 530 | if (node.__JSDOMParser__) { 531 | node.localName = tag.toLowerCase(); 532 | node.tagName = tag.toUpperCase(); 533 | return node; 534 | } 535 | 536 | var replacement = node.ownerDocument.createElement(tag); 537 | while (node.firstChild) { 538 | replacement.appendChild(node.firstChild); 539 | } 540 | node.parentNode.replaceChild(replacement, node); 541 | if (node.readability) 542 | replacement.readability = node.readability; 543 | 544 | for (var i = 0; i < node.attributes.length; i++) { 545 | try { 546 | replacement.setAttribute(node.attributes[i].name, node.attributes[i].value); 547 | } catch (ex) { 548 | /* it's possible for setAttribute() to throw if the attribute name 549 | * isn't a valid XML Name. Such attributes can however be parsed from 550 | * source in HTML docs, see https://github.com/whatwg/html/issues/4275, 551 | * so we can hit them here and then throw. We don't care about such 552 | * attributes so we ignore them. 553 | */ 554 | } 555 | } 556 | return replacement; 557 | }, 558 | 559 | /** 560 | * Prepare the article node for display. Clean out any inline styles, 561 | * iframes, forms, strip extraneous

tags, etc. 562 | * 563 | * @param Element 564 | * @return void 565 | **/ 566 | _prepArticle: function(articleContent) { 567 | this._cleanStyles(articleContent); 568 | 569 | // Check for data tables before we continue, to avoid removing items in 570 | // those tables, which will often be isolated even though they're 571 | // visually linked to other content-ful elements (text, images, etc.). 572 | this._markDataTables(articleContent); 573 | 574 | this._fixLazyImages(articleContent); 575 | 576 | // Clean out junk from the article content 577 | this._cleanConditionally(articleContent, "form"); 578 | this._cleanConditionally(articleContent, "fieldset"); 579 | this._clean(articleContent, "object"); 580 | this._clean(articleContent, "embed"); 581 | this._clean(articleContent, "h1"); 582 | this._clean(articleContent, "footer"); 583 | this._clean(articleContent, "link"); 584 | this._clean(articleContent, "aside"); 585 | 586 | // Clean out elements with little content that have "share" in their id/class combinations from final top candidates, 587 | // which means we don't remove the top candidates even they have "share". 588 | 589 | var shareElementThreshold = this.DEFAULT_CHAR_THRESHOLD; 590 | 591 | this._forEachNode(articleContent.children, function (topCandidate) { 592 | this._cleanMatchedNodes(topCandidate, function (node, matchString) { 593 | return this.REGEXPS.shareElements.test(matchString) && node.textContent.length < shareElementThreshold; 594 | }); 595 | }); 596 | 597 | // If there is only one h2 and its text content substantially equals article title, 598 | // they are probably using it as a header and not a subheader, 599 | // so remove it since we already extract the title separately. 600 | var h2 = articleContent.getElementsByTagName("h2"); 601 | if (h2.length === 1) { 602 | var lengthSimilarRate = (h2[0].textContent.length - this._articleTitle.length) / this._articleTitle.length; 603 | if (Math.abs(lengthSimilarRate) < 0.5) { 604 | var titlesMatch = false; 605 | if (lengthSimilarRate > 0) { 606 | titlesMatch = h2[0].textContent.includes(this._articleTitle); 607 | } else { 608 | titlesMatch = this._articleTitle.includes(h2[0].textContent); 609 | } 610 | if (titlesMatch) { 611 | this._clean(articleContent, "h2"); 612 | } 613 | } 614 | } 615 | 616 | this._clean(articleContent, "iframe"); 617 | this._clean(articleContent, "input"); 618 | this._clean(articleContent, "textarea"); 619 | this._clean(articleContent, "select"); 620 | this._clean(articleContent, "button"); 621 | this._cleanHeaders(articleContent); 622 | 623 | // Do these last as the previous stuff may have removed junk 624 | // that will affect these 625 | this._cleanConditionally(articleContent, "table"); 626 | this._cleanConditionally(articleContent, "ul"); 627 | this._cleanConditionally(articleContent, "div"); 628 | 629 | // Remove extra paragraphs 630 | this._removeNodes(articleContent.getElementsByTagName("p"), function (paragraph) { 631 | var imgCount = paragraph.getElementsByTagName("img").length; 632 | var embedCount = paragraph.getElementsByTagName("embed").length; 633 | var objectCount = paragraph.getElementsByTagName("object").length; 634 | // At this point, nasty iframes have been removed, only remain embedded video ones. 635 | var iframeCount = paragraph.getElementsByTagName("iframe").length; 636 | var totalCount = imgCount + embedCount + objectCount + iframeCount; 637 | 638 | return totalCount === 0 && !this._getInnerText(paragraph, false); 639 | }); 640 | 641 | this._forEachNode(this._getAllNodesWithTag(articleContent, ["br"]), function(br) { 642 | var next = this._nextElement(br.nextSibling); 643 | if (next && next.tagName == "P") 644 | br.parentNode.removeChild(br); 645 | }); 646 | 647 | // Remove single-cell tables 648 | this._forEachNode(this._getAllNodesWithTag(articleContent, ["table"]), function(table) { 649 | var tbody = this._hasSingleTagInsideElement(table, "TBODY") ? table.firstElementChild : table; 650 | if (this._hasSingleTagInsideElement(tbody, "TR")) { 651 | var row = tbody.firstElementChild; 652 | if (this._hasSingleTagInsideElement(row, "TD")) { 653 | var cell = row.firstElementChild; 654 | cell = this._setNodeTag(cell, this._everyNode(cell.childNodes, this._isPhrasingContent) ? "P" : "DIV"); 655 | table.parentNode.replaceChild(cell, table); 656 | } 657 | } 658 | }); 659 | }, 660 | 661 | /** 662 | * Initialize a node with the readability object. Also checks the 663 | * className/id for special names to add to its score. 664 | * 665 | * @param Element 666 | * @return void 667 | **/ 668 | _initializeNode: function(node) { 669 | node.readability = {"contentScore": 0}; 670 | 671 | switch (node.tagName) { 672 | case "DIV": 673 | node.readability.contentScore += 5; 674 | break; 675 | 676 | case "PRE": 677 | case "TD": 678 | case "BLOCKQUOTE": 679 | node.readability.contentScore += 3; 680 | break; 681 | 682 | case "ADDRESS": 683 | case "OL": 684 | case "UL": 685 | case "DL": 686 | case "DD": 687 | case "DT": 688 | case "LI": 689 | case "FORM": 690 | node.readability.contentScore -= 3; 691 | break; 692 | 693 | case "H1": 694 | case "H2": 695 | case "H3": 696 | case "H4": 697 | case "H5": 698 | case "H6": 699 | case "TH": 700 | node.readability.contentScore -= 5; 701 | break; 702 | } 703 | 704 | node.readability.contentScore += this._getClassWeight(node); 705 | }, 706 | 707 | _removeAndGetNext: function(node) { 708 | var nextNode = this._getNextNode(node, true); 709 | node.parentNode.removeChild(node); 710 | return nextNode; 711 | }, 712 | 713 | /** 714 | * Traverse the DOM from node to node, starting at the node passed in. 715 | * Pass true for the second parameter to indicate this node itself 716 | * (and its kids) are going away, and we want the next node over. 717 | * 718 | * Calling this in a loop will traverse the DOM depth-first. 719 | */ 720 | _getNextNode: function(node, ignoreSelfAndKids) { 721 | // First check for kids if those aren't being ignored 722 | if (!ignoreSelfAndKids && node.firstElementChild) { 723 | return node.firstElementChild; 724 | } 725 | // Then for siblings... 726 | if (node.nextElementSibling) { 727 | return node.nextElementSibling; 728 | } 729 | // And finally, move up the parent chain *and* find a sibling 730 | // (because this is depth-first traversal, we will have already 731 | // seen the parent nodes themselves). 732 | do { 733 | node = node.parentNode; 734 | } while (node && !node.nextElementSibling); 735 | return node && node.nextElementSibling; 736 | }, 737 | 738 | _checkByline: function(node, matchString) { 739 | if (this._articleByline) { 740 | return false; 741 | } 742 | 743 | if (node.getAttribute !== undefined) { 744 | var rel = node.getAttribute("rel"); 745 | var itemprop = node.getAttribute("itemprop"); 746 | } 747 | 748 | if ((rel === "author" || (itemprop && itemprop.indexOf("author") !== -1) || this.REGEXPS.byline.test(matchString)) && this._isValidByline(node.textContent)) { 749 | this._articleByline = node.textContent.trim(); 750 | return true; 751 | } 752 | 753 | return false; 754 | }, 755 | 756 | _getNodeAncestors: function(node, maxDepth) { 757 | maxDepth = maxDepth || 0; 758 | var i = 0, ancestors = []; 759 | while (node.parentNode) { 760 | ancestors.push(node.parentNode); 761 | if (maxDepth && ++i === maxDepth) 762 | break; 763 | node = node.parentNode; 764 | } 765 | return ancestors; 766 | }, 767 | 768 | /*** 769 | * grabArticle - Using a variety of metrics (content score, classname, element types), find the content that is 770 | * most likely to be the stuff a user wants to read. Then return it wrapped up in a div. 771 | * 772 | * @param page a document to run upon. Needs to be a full document, complete with body. 773 | * @return Element 774 | **/ 775 | _grabArticle: function (page) { 776 | this.log("**** grabArticle ****"); 777 | var doc = this._doc; 778 | var isPaging = (page !== null ? true: false); 779 | page = page ? page : this._doc.body; 780 | 781 | // We can't grab an article if we don't have a page! 782 | if (!page) { 783 | this.log("No body found in document. Abort."); 784 | return null; 785 | } 786 | 787 | var pageCacheHtml = page.innerHTML; 788 | 789 | while (true) { 790 | var stripUnlikelyCandidates = this._flagIsActive(this.FLAG_STRIP_UNLIKELYS); 791 | 792 | // First, node prepping. Trash nodes that look cruddy (like ones with the 793 | // class name "comment", etc), and turn divs into P tags where they have been 794 | // used inappropriately (as in, where they contain no other block level elements.) 795 | var elementsToScore = []; 796 | var node = this._doc.documentElement; 797 | 798 | while (node) { 799 | var matchString = node.className + " " + node.id; 800 | 801 | if (!this._isProbablyVisible(node)) { 802 | this.log("Removing hidden node - " + matchString); 803 | node = this._removeAndGetNext(node); 804 | continue; 805 | } 806 | 807 | // Check to see if this node is a byline, and remove it if it is. 808 | if (this._checkByline(node, matchString)) { 809 | node = this._removeAndGetNext(node); 810 | continue; 811 | } 812 | 813 | // Remove unlikely candidates 814 | if (stripUnlikelyCandidates) { 815 | if (this.REGEXPS.unlikelyCandidates.test(matchString) && 816 | !this.REGEXPS.okMaybeItsACandidate.test(matchString) && 817 | !this._hasAncestorTag(node, "table") && 818 | node.tagName !== "BODY" && 819 | node.tagName !== "A") { 820 | this.log("Removing unlikely candidate - " + matchString); 821 | node = this._removeAndGetNext(node); 822 | continue; 823 | } 824 | } 825 | 826 | // Remove DIV, SECTION, and HEADER nodes without any content(e.g. text, image, video, or iframe). 827 | if ((node.tagName === "DIV" || node.tagName === "SECTION" || node.tagName === "HEADER" || 828 | node.tagName === "H1" || node.tagName === "H2" || node.tagName === "H3" || 829 | node.tagName === "H4" || node.tagName === "H5" || node.tagName === "H6") && 830 | this._isElementWithoutContent(node)) { 831 | node = this._removeAndGetNext(node); 832 | continue; 833 | } 834 | 835 | if (this.DEFAULT_TAGS_TO_SCORE.indexOf(node.tagName) !== -1) { 836 | elementsToScore.push(node); 837 | } 838 | 839 | // Turn all divs that don't have children block level elements into p's 840 | if (node.tagName === "DIV") { 841 | // Put phrasing content into paragraphs. 842 | var p = null; 843 | var childNode = node.firstChild; 844 | while (childNode) { 845 | var nextSibling = childNode.nextSibling; 846 | if (this._isPhrasingContent(childNode)) { 847 | if (p !== null) { 848 | p.appendChild(childNode); 849 | } else if (!this._isWhitespace(childNode)) { 850 | p = doc.createElement("p"); 851 | node.replaceChild(p, childNode); 852 | p.appendChild(childNode); 853 | } 854 | } else if (p !== null) { 855 | while (p.lastChild && this._isWhitespace(p.lastChild)) { 856 | p.removeChild(p.lastChild); 857 | } 858 | p = null; 859 | } 860 | childNode = nextSibling; 861 | } 862 | 863 | // Sites like http://mobile.slate.com encloses each paragraph with a DIV 864 | // element. DIVs with only a P element inside and no text content can be 865 | // safely converted into plain P elements to avoid confusing the scoring 866 | // algorithm with DIVs with are, in practice, paragraphs. 867 | if (this._hasSingleTagInsideElement(node, "P") && this._getLinkDensity(node) < 0.25) { 868 | var newNode = node.children[0]; 869 | node.parentNode.replaceChild(newNode, node); 870 | node = newNode; 871 | elementsToScore.push(node); 872 | } else if (!this._hasChildBlockElement(node)) { 873 | node = this._setNodeTag(node, "P"); 874 | elementsToScore.push(node); 875 | } 876 | } 877 | node = this._getNextNode(node); 878 | } 879 | 880 | /** 881 | * Loop through all paragraphs, and assign a score to them based on how content-y they look. 882 | * Then add their score to their parent node. 883 | * 884 | * A score is determined by things like number of commas, class names, etc. Maybe eventually link density. 885 | **/ 886 | var candidates = []; 887 | this._forEachNode(elementsToScore, function(elementToScore) { 888 | if (!elementToScore.parentNode || typeof(elementToScore.parentNode.tagName) === "undefined") 889 | return; 890 | 891 | // If this paragraph is less than 25 characters, don't even count it. 892 | var innerText = this._getInnerText(elementToScore); 893 | if (innerText.length < 25) 894 | return; 895 | 896 | // Exclude nodes with no ancestor. 897 | var ancestors = this._getNodeAncestors(elementToScore, 3); 898 | if (ancestors.length === 0) 899 | return; 900 | 901 | var contentScore = 0; 902 | 903 | // Add a point for the paragraph itself as a base. 904 | contentScore += 1; 905 | 906 | // Add points for any commas within this paragraph. 907 | contentScore += innerText.split(",").length; 908 | 909 | // For every 100 characters in this paragraph, add another point. Up to 3 points. 910 | contentScore += Math.min(Math.floor(innerText.length / 100), 3); 911 | 912 | // Initialize and score ancestors. 913 | this._forEachNode(ancestors, function(ancestor, level) { 914 | if (!ancestor.tagName || !ancestor.parentNode || typeof(ancestor.parentNode.tagName) === "undefined") 915 | return; 916 | 917 | if (typeof(ancestor.readability) === "undefined") { 918 | this._initializeNode(ancestor); 919 | candidates.push(ancestor); 920 | } 921 | 922 | // Node score divider: 923 | // - parent: 1 (no division) 924 | // - grandparent: 2 925 | // - great grandparent+: ancestor level * 3 926 | if (level === 0) 927 | var scoreDivider = 1; 928 | else if (level === 1) 929 | scoreDivider = 2; 930 | else 931 | scoreDivider = level * 3; 932 | ancestor.readability.contentScore += contentScore / scoreDivider; 933 | }); 934 | }); 935 | 936 | // After we've calculated scores, loop through all of the possible 937 | // candidate nodes we found and find the one with the highest score. 938 | var topCandidates = []; 939 | for (var c = 0, cl = candidates.length; c < cl; c += 1) { 940 | var candidate = candidates[c]; 941 | 942 | // Scale the final candidates score based on link density. Good content 943 | // should have a relatively small link density (5% or less) and be mostly 944 | // unaffected by this operation. 945 | var candidateScore = candidate.readability.contentScore * (1 - this._getLinkDensity(candidate)); 946 | candidate.readability.contentScore = candidateScore; 947 | 948 | this.log("Candidate:", candidate, "with score " + candidateScore); 949 | 950 | for (var t = 0; t < this._nbTopCandidates; t++) { 951 | var aTopCandidate = topCandidates[t]; 952 | 953 | if (!aTopCandidate || candidateScore > aTopCandidate.readability.contentScore) { 954 | topCandidates.splice(t, 0, candidate); 955 | if (topCandidates.length > this._nbTopCandidates) 956 | topCandidates.pop(); 957 | break; 958 | } 959 | } 960 | } 961 | 962 | var topCandidate = topCandidates[0] || null; 963 | var neededToCreateTopCandidate = false; 964 | var parentOfTopCandidate; 965 | 966 | // If we still have no top candidate, just use the body as a last resort. 967 | // We also have to copy the body node so it is something we can modify. 968 | if (topCandidate === null || topCandidate.tagName === "BODY") { 969 | // Move all of the page's children into topCandidate 970 | topCandidate = doc.createElement("DIV"); 971 | neededToCreateTopCandidate = true; 972 | // Move everything (not just elements, also text nodes etc.) into the container 973 | // so we even include text directly in the body: 974 | var kids = page.childNodes; 975 | while (kids.length) { 976 | this.log("Moving child out:", kids[0]); 977 | topCandidate.appendChild(kids[0]); 978 | } 979 | 980 | page.appendChild(topCandidate); 981 | 982 | this._initializeNode(topCandidate); 983 | } else if (topCandidate) { 984 | // Find a better top candidate node if it contains (at least three) nodes which belong to `topCandidates` array 985 | // and whose scores are quite closed with current `topCandidate` node. 986 | var alternativeCandidateAncestors = []; 987 | for (var i = 1; i < topCandidates.length; i++) { 988 | if (topCandidates[i].readability.contentScore / topCandidate.readability.contentScore >= 0.75) { 989 | alternativeCandidateAncestors.push(this._getNodeAncestors(topCandidates[i])); 990 | } 991 | } 992 | var MINIMUM_TOPCANDIDATES = 3; 993 | if (alternativeCandidateAncestors.length >= MINIMUM_TOPCANDIDATES) { 994 | parentOfTopCandidate = topCandidate.parentNode; 995 | while (parentOfTopCandidate.tagName !== "BODY") { 996 | var listsContainingThisAncestor = 0; 997 | for (var ancestorIndex = 0; ancestorIndex < alternativeCandidateAncestors.length && listsContainingThisAncestor < MINIMUM_TOPCANDIDATES; ancestorIndex++) { 998 | listsContainingThisAncestor += Number(alternativeCandidateAncestors[ancestorIndex].includes(parentOfTopCandidate)); 999 | } 1000 | if (listsContainingThisAncestor >= MINIMUM_TOPCANDIDATES) { 1001 | topCandidate = parentOfTopCandidate; 1002 | break; 1003 | } 1004 | parentOfTopCandidate = parentOfTopCandidate.parentNode; 1005 | } 1006 | } 1007 | if (!topCandidate.readability) { 1008 | this._initializeNode(topCandidate); 1009 | } 1010 | 1011 | // Because of our bonus system, parents of candidates might have scores 1012 | // themselves. They get half of the node. There won't be nodes with higher 1013 | // scores than our topCandidate, but if we see the score going *up* in the first 1014 | // few steps up the tree, that's a decent sign that there might be more content 1015 | // lurking in other places that we want to unify in. The sibling stuff 1016 | // below does some of that - but only if we've looked high enough up the DOM 1017 | // tree. 1018 | parentOfTopCandidate = topCandidate.parentNode; 1019 | var lastScore = topCandidate.readability.contentScore; 1020 | // The scores shouldn't get too low. 1021 | var scoreThreshold = lastScore / 3; 1022 | while (parentOfTopCandidate.tagName !== "BODY") { 1023 | if (!parentOfTopCandidate.readability) { 1024 | parentOfTopCandidate = parentOfTopCandidate.parentNode; 1025 | continue; 1026 | } 1027 | var parentScore = parentOfTopCandidate.readability.contentScore; 1028 | if (parentScore < scoreThreshold) 1029 | break; 1030 | if (parentScore > lastScore) { 1031 | // Alright! We found a better parent to use. 1032 | topCandidate = parentOfTopCandidate; 1033 | break; 1034 | } 1035 | lastScore = parentOfTopCandidate.readability.contentScore; 1036 | parentOfTopCandidate = parentOfTopCandidate.parentNode; 1037 | } 1038 | 1039 | // If the top candidate is the only child, use parent instead. This will help sibling 1040 | // joining logic when adjacent content is actually located in parent's sibling node. 1041 | parentOfTopCandidate = topCandidate.parentNode; 1042 | while (parentOfTopCandidate.tagName != "BODY" && parentOfTopCandidate.children.length == 1) { 1043 | topCandidate = parentOfTopCandidate; 1044 | parentOfTopCandidate = topCandidate.parentNode; 1045 | } 1046 | if (!topCandidate.readability) { 1047 | this._initializeNode(topCandidate); 1048 | } 1049 | } 1050 | 1051 | // Now that we have the top candidate, look through its siblings for content 1052 | // that might also be related. Things like preambles, content split by ads 1053 | // that we removed, etc. 1054 | var articleContent = doc.createElement("DIV"); 1055 | if (isPaging) 1056 | articleContent.id = "readability-content"; 1057 | 1058 | var siblingScoreThreshold = Math.max(10, topCandidate.readability.contentScore * 0.2); 1059 | // Keep potential top candidate's parent node to try to get text direction of it later. 1060 | parentOfTopCandidate = topCandidate.parentNode; 1061 | var siblings = parentOfTopCandidate.children; 1062 | 1063 | for (var s = 0, sl = siblings.length; s < sl; s++) { 1064 | var sibling = siblings[s]; 1065 | var append = false; 1066 | 1067 | this.log("Looking at sibling node:", sibling, sibling.readability ? ("with score " + sibling.readability.contentScore) : ""); 1068 | this.log("Sibling has score", sibling.readability ? sibling.readability.contentScore : "Unknown"); 1069 | 1070 | if (sibling === topCandidate) { 1071 | append = true; 1072 | } else { 1073 | var contentBonus = 0; 1074 | 1075 | // Give a bonus if sibling nodes and top candidates have the example same classname 1076 | if (sibling.className === topCandidate.className && topCandidate.className !== "") 1077 | contentBonus += topCandidate.readability.contentScore * 0.2; 1078 | 1079 | if (sibling.readability && 1080 | ((sibling.readability.contentScore + contentBonus) >= siblingScoreThreshold)) { 1081 | append = true; 1082 | } else if (sibling.nodeName === "P") { 1083 | var linkDensity = this._getLinkDensity(sibling); 1084 | var nodeContent = this._getInnerText(sibling); 1085 | var nodeLength = nodeContent.length; 1086 | 1087 | if (nodeLength > 80 && linkDensity < 0.25) { 1088 | append = true; 1089 | } else if (nodeLength < 80 && nodeLength > 0 && linkDensity === 0 && 1090 | nodeContent.search(/\.( |$)/) !== -1) { 1091 | append = true; 1092 | } 1093 | } 1094 | } 1095 | 1096 | if (append) { 1097 | this.log("Appending node:", sibling); 1098 | 1099 | if (this.ALTER_TO_DIV_EXCEPTIONS.indexOf(sibling.nodeName) === -1) { 1100 | // We have a node that isn't a common block level element, like a form or td tag. 1101 | // Turn it into a div so it doesn't get filtered out later by accident. 1102 | this.log("Altering sibling:", sibling, "to div."); 1103 | 1104 | sibling = this._setNodeTag(sibling, "DIV"); 1105 | } 1106 | 1107 | articleContent.appendChild(sibling); 1108 | // siblings is a reference to the children array, and 1109 | // sibling is removed from the array when we call appendChild(). 1110 | // As a result, we must revisit this index since the nodes 1111 | // have been shifted. 1112 | s -= 1; 1113 | sl -= 1; 1114 | } 1115 | } 1116 | 1117 | if (this._debug) 1118 | this.log("Article content pre-prep: " + articleContent.innerHTML); 1119 | // So we have all of the content that we need. Now we clean it up for presentation. 1120 | this._prepArticle(articleContent); 1121 | if (this._debug) 1122 | this.log("Article content post-prep: " + articleContent.innerHTML); 1123 | 1124 | if (neededToCreateTopCandidate) { 1125 | // We already created a fake div thing, and there wouldn't have been any siblings left 1126 | // for the previous loop, so there's no point trying to create a new div, and then 1127 | // move all the children over. Just assign IDs and class names here. No need to append 1128 | // because that already happened anyway. 1129 | topCandidate.id = "readability-page-1"; 1130 | topCandidate.className = "page"; 1131 | } else { 1132 | var div = doc.createElement("DIV"); 1133 | div.id = "readability-page-1"; 1134 | div.className = "page"; 1135 | var children = articleContent.childNodes; 1136 | while (children.length) { 1137 | div.appendChild(children[0]); 1138 | } 1139 | articleContent.appendChild(div); 1140 | } 1141 | 1142 | if (this._debug) 1143 | this.log("Article content after paging: " + articleContent.innerHTML); 1144 | 1145 | var parseSuccessful = true; 1146 | 1147 | // Now that we've gone through the full algorithm, check to see if 1148 | // we got any meaningful content. If we didn't, we may need to re-run 1149 | // grabArticle with different flags set. This gives us a higher likelihood of 1150 | // finding the content, and the sieve approach gives us a higher likelihood of 1151 | // finding the -right- content. 1152 | var textLength = this._getInnerText(articleContent, true).length; 1153 | if (textLength < this._charThreshold) { 1154 | parseSuccessful = false; 1155 | page.innerHTML = pageCacheHtml; 1156 | 1157 | if (this._flagIsActive(this.FLAG_STRIP_UNLIKELYS)) { 1158 | this._removeFlag(this.FLAG_STRIP_UNLIKELYS); 1159 | this._attempts.push({articleContent: articleContent, textLength: textLength}); 1160 | } else if (this._flagIsActive(this.FLAG_WEIGHT_CLASSES)) { 1161 | this._removeFlag(this.FLAG_WEIGHT_CLASSES); 1162 | this._attempts.push({articleContent: articleContent, textLength: textLength}); 1163 | } else if (this._flagIsActive(this.FLAG_CLEAN_CONDITIONALLY)) { 1164 | this._removeFlag(this.FLAG_CLEAN_CONDITIONALLY); 1165 | this._attempts.push({articleContent: articleContent, textLength: textLength}); 1166 | } else { 1167 | this._attempts.push({articleContent: articleContent, textLength: textLength}); 1168 | // No luck after removing flags, just return the longest text we found during the different loops 1169 | this._attempts.sort(function (a, b) { 1170 | return b.textLength - a.textLength; 1171 | }); 1172 | 1173 | // But first check if we actually have something 1174 | if (!this._attempts[0].textLength) { 1175 | return null; 1176 | } 1177 | 1178 | articleContent = this._attempts[0].articleContent; 1179 | parseSuccessful = true; 1180 | } 1181 | } 1182 | 1183 | if (parseSuccessful) { 1184 | // Find out text direction from ancestors of final top candidate. 1185 | var ancestors = [parentOfTopCandidate, topCandidate].concat(this._getNodeAncestors(parentOfTopCandidate)); 1186 | this._someNode(ancestors, function(ancestor) { 1187 | if (!ancestor.tagName) 1188 | return false; 1189 | var articleDir = ancestor.getAttribute("dir"); 1190 | if (articleDir) { 1191 | this._articleDir = articleDir; 1192 | return true; 1193 | } 1194 | return false; 1195 | }); 1196 | return articleContent; 1197 | } 1198 | } 1199 | }, 1200 | 1201 | /** 1202 | * Check whether the input string could be a byline. 1203 | * This verifies that the input is a string, and that the length 1204 | * is less than 100 chars. 1205 | * 1206 | * @param possibleByline {string} - a string to check whether its a byline. 1207 | * @return Boolean - whether the input string is a byline. 1208 | */ 1209 | _isValidByline: function(byline) { 1210 | if (typeof byline == "string" || byline instanceof String) { 1211 | byline = byline.trim(); 1212 | return (byline.length > 0) && (byline.length < 100); 1213 | } 1214 | return false; 1215 | }, 1216 | 1217 | /** 1218 | * Attempts to get excerpt and byline metadata for the article. 1219 | * 1220 | * @return Object with optional "excerpt" and "byline" properties 1221 | */ 1222 | _getArticleMetadata: function() { 1223 | var metadata = {}; 1224 | var values = {}; 1225 | var metaElements = this._doc.getElementsByTagName("meta"); 1226 | 1227 | // property is a space-separated list of values 1228 | var propertyPattern = /\s*(dc|dcterm|og|twitter)\s*:\s*(author|creator|description|title|site_name)\s*/gi; 1229 | 1230 | // name is a single value 1231 | var namePattern = /^\s*(?:(dc|dcterm|og|twitter|weibo:(article|webpage))\s*[\.:]\s*)?(author|creator|description|title|site_name)\s*$/i; 1232 | 1233 | // Find description tags. 1234 | this._forEachNode(metaElements, function(element) { 1235 | var elementName = element.getAttribute("name"); 1236 | var elementProperty = element.getAttribute("property"); 1237 | var content = element.getAttribute("content"); 1238 | if (!content) { 1239 | return; 1240 | } 1241 | var matches = null; 1242 | var name = null; 1243 | 1244 | if (elementProperty) { 1245 | matches = elementProperty.match(propertyPattern); 1246 | if (matches) { 1247 | for (var i = matches.length - 1; i >= 0; i--) { 1248 | // Convert to lowercase, and remove any whitespace 1249 | // so we can match below. 1250 | name = matches[i].toLowerCase().replace(/\s/g, ""); 1251 | // multiple authors 1252 | values[name] = content.trim(); 1253 | } 1254 | } 1255 | } 1256 | if (!matches && elementName && namePattern.test(elementName)) { 1257 | name = elementName; 1258 | if (content) { 1259 | // Convert to lowercase, remove any whitespace, and convert dots 1260 | // to colons so we can match below. 1261 | name = name.toLowerCase().replace(/\s/g, "").replace(/\./g, ":"); 1262 | values[name] = content.trim(); 1263 | } 1264 | } 1265 | }); 1266 | 1267 | // get title 1268 | metadata.title = values["dc:title"] || 1269 | values["dcterm:title"] || 1270 | values["og:title"] || 1271 | values["weibo:article:title"] || 1272 | values["weibo:webpage:title"] || 1273 | values["title"] || 1274 | values["twitter:title"]; 1275 | 1276 | if (!metadata.title) { 1277 | metadata.title = this._getArticleTitle(); 1278 | } 1279 | 1280 | // get author 1281 | metadata.byline = values["dc:creator"] || 1282 | values["dcterm:creator"] || 1283 | values["author"]; 1284 | 1285 | // get description 1286 | metadata.excerpt = values["dc:description"] || 1287 | values["dcterm:description"] || 1288 | values["og:description"] || 1289 | values["weibo:article:description"] || 1290 | values["weibo:webpage:description"] || 1291 | values["description"] || 1292 | values["twitter:description"]; 1293 | 1294 | // get site name 1295 | metadata.siteName = values["og:site_name"]; 1296 | 1297 | return metadata; 1298 | }, 1299 | 1300 | /** 1301 | * Removes script tags from the document. 1302 | * 1303 | * @param Element 1304 | **/ 1305 | _removeScripts: function(doc) { 1306 | this._removeNodes(doc.getElementsByTagName("script"), function(scriptNode) { 1307 | scriptNode.nodeValue = ""; 1308 | scriptNode.removeAttribute("src"); 1309 | return true; 1310 | }); 1311 | this._removeNodes(doc.getElementsByTagName("noscript")); 1312 | }, 1313 | 1314 | /** 1315 | * Check if this node has only whitespace and a single element with given tag 1316 | * Returns false if the DIV node contains non-empty text nodes 1317 | * or if it contains no element with given tag or more than 1 element. 1318 | * 1319 | * @param Element 1320 | * @param string tag of child element 1321 | **/ 1322 | _hasSingleTagInsideElement: function(element, tag) { 1323 | // There should be exactly 1 element child with given tag 1324 | if (element.children.length != 1 || element.children[0].tagName !== tag) { 1325 | return false; 1326 | } 1327 | 1328 | // And there should be no text nodes with real content 1329 | return !this._someNode(element.childNodes, function(node) { 1330 | return node.nodeType === this.TEXT_NODE && 1331 | this.REGEXPS.hasContent.test(node.textContent); 1332 | }); 1333 | }, 1334 | 1335 | _isElementWithoutContent: function(node) { 1336 | return node.nodeType === this.ELEMENT_NODE && 1337 | node.textContent.trim().length == 0 && 1338 | (node.children.length == 0 || 1339 | node.children.length == node.getElementsByTagName("br").length + node.getElementsByTagName("hr").length); 1340 | }, 1341 | 1342 | /** 1343 | * Determine whether element has any children block level elements. 1344 | * 1345 | * @param Element 1346 | */ 1347 | _hasChildBlockElement: function (element) { 1348 | return this._someNode(element.childNodes, function(node) { 1349 | return this.DIV_TO_P_ELEMS.indexOf(node.tagName) !== -1 || 1350 | this._hasChildBlockElement(node); 1351 | }); 1352 | }, 1353 | 1354 | /*** 1355 | * Determine if a node qualifies as phrasing content. 1356 | * https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content 1357 | **/ 1358 | _isPhrasingContent: function(node) { 1359 | return node.nodeType === this.TEXT_NODE || this.PHRASING_ELEMS.indexOf(node.tagName) !== -1 || 1360 | ((node.tagName === "A" || node.tagName === "DEL" || node.tagName === "INS") && 1361 | this._everyNode(node.childNodes, this._isPhrasingContent)); 1362 | }, 1363 | 1364 | _isWhitespace: function(node) { 1365 | return (node.nodeType === this.TEXT_NODE && node.textContent.trim().length === 0) || 1366 | (node.nodeType === this.ELEMENT_NODE && node.tagName === "BR"); 1367 | }, 1368 | 1369 | /** 1370 | * Get the inner text of a node - cross browser compatibly. 1371 | * This also strips out any excess whitespace to be found. 1372 | * 1373 | * @param Element 1374 | * @param Boolean normalizeSpaces (default: true) 1375 | * @return string 1376 | **/ 1377 | _getInnerText: function(e, normalizeSpaces) { 1378 | normalizeSpaces = (typeof normalizeSpaces === "undefined") ? true : normalizeSpaces; 1379 | var textContent = e.textContent.trim(); 1380 | 1381 | if (normalizeSpaces) { 1382 | return textContent.replace(this.REGEXPS.normalize, " "); 1383 | } 1384 | return textContent; 1385 | }, 1386 | 1387 | /** 1388 | * Get the number of times a string s appears in the node e. 1389 | * 1390 | * @param Element 1391 | * @param string - what to split on. Default is "," 1392 | * @return number (integer) 1393 | **/ 1394 | _getCharCount: function(e, s) { 1395 | s = s || ","; 1396 | return this._getInnerText(e).split(s).length - 1; 1397 | }, 1398 | 1399 | /** 1400 | * Remove the style attribute on every e and under. 1401 | * TODO: Test if getElementsByTagName(*) is faster. 1402 | * 1403 | * @param Element 1404 | * @return void 1405 | **/ 1406 | _cleanStyles: function(e) { 1407 | if (!e || e.tagName.toLowerCase() === "svg") 1408 | return; 1409 | 1410 | // Remove `style` and deprecated presentational attributes 1411 | for (var i = 0; i < this.PRESENTATIONAL_ATTRIBUTES.length; i++) { 1412 | e.removeAttribute(this.PRESENTATIONAL_ATTRIBUTES[i]); 1413 | } 1414 | 1415 | if (this.DEPRECATED_SIZE_ATTRIBUTE_ELEMS.indexOf(e.tagName) !== -1) { 1416 | e.removeAttribute("width"); 1417 | e.removeAttribute("height"); 1418 | } 1419 | 1420 | var cur = e.firstElementChild; 1421 | while (cur !== null) { 1422 | this._cleanStyles(cur); 1423 | cur = cur.nextElementSibling; 1424 | } 1425 | }, 1426 | 1427 | /** 1428 | * Get the density of links as a percentage of the content 1429 | * This is the amount of text that is inside a link divided by the total text in the node. 1430 | * 1431 | * @param Element 1432 | * @return number (float) 1433 | **/ 1434 | _getLinkDensity: function(element) { 1435 | var textLength = this._getInnerText(element).length; 1436 | if (textLength === 0) 1437 | return 0; 1438 | 1439 | var linkLength = 0; 1440 | 1441 | // XXX implement _reduceNodeList? 1442 | this._forEachNode(element.getElementsByTagName("a"), function(linkNode) { 1443 | linkLength += this._getInnerText(linkNode).length; 1444 | }); 1445 | 1446 | return linkLength / textLength; 1447 | }, 1448 | 1449 | /** 1450 | * Get an elements class/id weight. Uses regular expressions to tell if this 1451 | * element looks good or bad. 1452 | * 1453 | * @param Element 1454 | * @return number (Integer) 1455 | **/ 1456 | _getClassWeight: function(e) { 1457 | if (!this._flagIsActive(this.FLAG_WEIGHT_CLASSES)) 1458 | return 0; 1459 | 1460 | var weight = 0; 1461 | 1462 | // Look for a special classname 1463 | if (typeof(e.className) === "string" && e.className !== "") { 1464 | if (this.REGEXPS.negative.test(e.className)) 1465 | weight -= 25; 1466 | 1467 | if (this.REGEXPS.positive.test(e.className)) 1468 | weight += 25; 1469 | } 1470 | 1471 | // Look for a special ID 1472 | if (typeof(e.id) === "string" && e.id !== "") { 1473 | if (this.REGEXPS.negative.test(e.id)) 1474 | weight -= 25; 1475 | 1476 | if (this.REGEXPS.positive.test(e.id)) 1477 | weight += 25; 1478 | } 1479 | 1480 | return weight; 1481 | }, 1482 | 1483 | /** 1484 | * Clean a node of all elements of type "tag". 1485 | * (Unless it's a youtube/vimeo video. People love movies.) 1486 | * 1487 | * @param Element 1488 | * @param string tag to clean 1489 | * @return void 1490 | **/ 1491 | _clean: function(e, tag) { 1492 | var isEmbed = ["object", "embed", "iframe"].indexOf(tag) !== -1; 1493 | 1494 | this._removeNodes(e.getElementsByTagName(tag), function(element) { 1495 | // Allow youtube and vimeo videos through as people usually want to see those. 1496 | if (isEmbed) { 1497 | // First, check the elements attributes to see if any of them contain youtube or vimeo 1498 | for (var i = 0; i < element.attributes.length; i++) { 1499 | if (this.REGEXPS.videos.test(element.attributes[i].value)) { 1500 | return false; 1501 | } 1502 | } 1503 | 1504 | // For embed with tag, check inner HTML as well. 1505 | if (element.tagName === "object" && this.REGEXPS.videos.test(element.innerHTML)) { 1506 | return false; 1507 | } 1508 | } 1509 | 1510 | return true; 1511 | }); 1512 | }, 1513 | 1514 | /** 1515 | * Check if a given node has one of its ancestor tag name matching the 1516 | * provided one. 1517 | * @param HTMLElement node 1518 | * @param String tagName 1519 | * @param Number maxDepth 1520 | * @param Function filterFn a filter to invoke to determine whether this node 'counts' 1521 | * @return Boolean 1522 | */ 1523 | _hasAncestorTag: function(node, tagName, maxDepth, filterFn) { 1524 | maxDepth = maxDepth || 3; 1525 | tagName = tagName.toUpperCase(); 1526 | var depth = 0; 1527 | while (node.parentNode) { 1528 | if (maxDepth > 0 && depth > maxDepth) 1529 | return false; 1530 | if (node.parentNode.tagName === tagName && (!filterFn || filterFn(node.parentNode))) 1531 | return true; 1532 | node = node.parentNode; 1533 | depth++; 1534 | } 1535 | return false; 1536 | }, 1537 | 1538 | /** 1539 | * Return an object indicating how many rows and columns this table has. 1540 | */ 1541 | _getRowAndColumnCount: function(table) { 1542 | var rows = 0; 1543 | var columns = 0; 1544 | var trs = table.getElementsByTagName("tr"); 1545 | for (var i = 0; i < trs.length; i++) { 1546 | var rowspan = trs[i].getAttribute("rowspan") || 0; 1547 | if (rowspan) { 1548 | rowspan = parseInt(rowspan, 10); 1549 | } 1550 | rows += (rowspan || 1); 1551 | 1552 | // Now look for column-related info 1553 | var columnsInThisRow = 0; 1554 | var cells = trs[i].getElementsByTagName("td"); 1555 | for (var j = 0; j < cells.length; j++) { 1556 | var colspan = cells[j].getAttribute("colspan") || 0; 1557 | if (colspan) { 1558 | colspan = parseInt(colspan, 10); 1559 | } 1560 | columnsInThisRow += (colspan || 1); 1561 | } 1562 | columns = Math.max(columns, columnsInThisRow); 1563 | } 1564 | return {rows: rows, columns: columns}; 1565 | }, 1566 | 1567 | /** 1568 | * Look for 'data' (as opposed to 'layout') tables, for which we use 1569 | * similar checks as 1570 | * https://dxr.mozilla.org/mozilla-central/rev/71224049c0b52ab190564d3ea0eab089a159a4cf/accessible/html/HTMLTableAccessible.cpp#920 1571 | */ 1572 | _markDataTables: function(root) { 1573 | var tables = root.getElementsByTagName("table"); 1574 | for (var i = 0; i < tables.length; i++) { 1575 | var table = tables[i]; 1576 | var role = table.getAttribute("role"); 1577 | if (role == "presentation") { 1578 | table._readabilityDataTable = false; 1579 | continue; 1580 | } 1581 | var datatable = table.getAttribute("datatable"); 1582 | if (datatable == "0") { 1583 | table._readabilityDataTable = false; 1584 | continue; 1585 | } 1586 | var summary = table.getAttribute("summary"); 1587 | if (summary) { 1588 | table._readabilityDataTable = true; 1589 | continue; 1590 | } 1591 | 1592 | var caption = table.getElementsByTagName("caption")[0]; 1593 | if (caption && caption.childNodes.length > 0) { 1594 | table._readabilityDataTable = true; 1595 | continue; 1596 | } 1597 | 1598 | // If the table has a descendant with any of these tags, consider a data table: 1599 | var dataTableDescendants = ["col", "colgroup", "tfoot", "thead", "th"]; 1600 | var descendantExists = function(tag) { 1601 | return !!table.getElementsByTagName(tag)[0]; 1602 | }; 1603 | if (dataTableDescendants.some(descendantExists)) { 1604 | this.log("Data table because found data-y descendant"); 1605 | table._readabilityDataTable = true; 1606 | continue; 1607 | } 1608 | 1609 | // Nested tables indicate a layout table: 1610 | if (table.getElementsByTagName("table")[0]) { 1611 | table._readabilityDataTable = false; 1612 | continue; 1613 | } 1614 | 1615 | var sizeInfo = this._getRowAndColumnCount(table); 1616 | if (sizeInfo.rows >= 10 || sizeInfo.columns > 4) { 1617 | table._readabilityDataTable = true; 1618 | continue; 1619 | } 1620 | // Now just go by size entirely: 1621 | table._readabilityDataTable = sizeInfo.rows * sizeInfo.columns > 10; 1622 | } 1623 | }, 1624 | 1625 | /* convert images and figures that have properties like data-src into images that can be loaded without JS */ 1626 | _fixLazyImages: function (root) { 1627 | this._forEachNode(this._getAllNodesWithTag(root, ["img", "picture", "figure"]), function (elem) { 1628 | // also check for "null" to work around https://github.com/jsdom/jsdom/issues/2580 1629 | if ((!elem.src && (!elem.srcset || elem.srcset == "null")) || elem.className.toLowerCase().indexOf("lazy") !== -1) { 1630 | for (var i = 0; i < elem.attributes.length; i++) { 1631 | var attr = elem.attributes[i]; 1632 | if (attr.name === "src" || attr.name === "srcset") { 1633 | continue; 1634 | } 1635 | var copyTo = null; 1636 | if (/\.(jpg|jpeg|png|webp)\s+\d/.test(attr.value)) { 1637 | copyTo = "srcset"; 1638 | } else if (/^\s*\S+\.(jpg|jpeg|png|webp)\S*\s*$/.test(attr.value)) { 1639 | copyTo = "src"; 1640 | } 1641 | if (copyTo) { 1642 | //if this is an img or picture, set the attribute directly 1643 | if (elem.tagName === "IMG" || elem.tagName === "PICTURE") { 1644 | elem.setAttribute(copyTo, attr.value); 1645 | } else if (elem.tagName === "FIGURE" && !this._getAllNodesWithTag(elem, ["img", "picture"]).length) { 1646 | //if the item is a
that does not contain an image or picture, create one and place it inside the figure 1647 | //see the nytimes-3 testcase for an example 1648 | var img = this._doc.createElement("img"); 1649 | img.setAttribute(copyTo, attr.value); 1650 | elem.appendChild(img); 1651 | } 1652 | } 1653 | } 1654 | } 1655 | }); 1656 | }, 1657 | 1658 | /** 1659 | * Clean an element of all tags of type "tag" if they look fishy. 1660 | * "Fishy" is an algorithm based on content length, classnames, link density, number of images & embeds, etc. 1661 | * 1662 | * @return void 1663 | **/ 1664 | _cleanConditionally: function(e, tag) { 1665 | if (!this._flagIsActive(this.FLAG_CLEAN_CONDITIONALLY)) 1666 | return; 1667 | 1668 | var isList = tag === "ul" || tag === "ol"; 1669 | 1670 | // Gather counts for other typical elements embedded within. 1671 | // Traverse backwards so we can remove nodes at the same time 1672 | // without effecting the traversal. 1673 | // 1674 | // TODO: Consider taking into account original contentScore here. 1675 | this._removeNodes(e.getElementsByTagName(tag), function(node) { 1676 | // First check if this node IS data table, in which case don't remove it. 1677 | var isDataTable = function(t) { 1678 | return t._readabilityDataTable; 1679 | }; 1680 | 1681 | if (tag === "table" && isDataTable(node)) { 1682 | return false; 1683 | } 1684 | 1685 | // Next check if we're inside a data table, in which case don't remove it as well. 1686 | if (this._hasAncestorTag(node, "table", -1, isDataTable)) { 1687 | return false; 1688 | } 1689 | 1690 | var weight = this._getClassWeight(node); 1691 | var contentScore = 0; 1692 | 1693 | this.log("Cleaning Conditionally", node); 1694 | 1695 | if (weight + contentScore < 0) { 1696 | return true; 1697 | } 1698 | 1699 | if (this._getCharCount(node, ",") < 10) { 1700 | // If there are not very many commas, and the number of 1701 | // non-paragraph elements is more than paragraphs or other 1702 | // ominous signs, remove the element. 1703 | var p = node.getElementsByTagName("p").length; 1704 | var img = node.getElementsByTagName("img").length; 1705 | var li = node.getElementsByTagName("li").length - 100; 1706 | var input = node.getElementsByTagName("input").length; 1707 | 1708 | var embedCount = 0; 1709 | var embeds = this._concatNodeLists( 1710 | node.getElementsByTagName("object"), 1711 | node.getElementsByTagName("embed"), 1712 | node.getElementsByTagName("iframe")); 1713 | 1714 | for (var i = 0; i < embeds.length; i++) { 1715 | // If this embed has attribute that matches video regex, don't delete it. 1716 | for (var j = 0; j < embeds[i].attributes.length; j++) { 1717 | if (this.REGEXPS.videos.test(embeds[i].attributes[j].value)) { 1718 | return false; 1719 | } 1720 | } 1721 | 1722 | // For embed with tag, check inner HTML as well. 1723 | if (embeds[i].tagName === "object" && this.REGEXPS.videos.test(embeds[i].innerHTML)) { 1724 | return false; 1725 | } 1726 | 1727 | embedCount++; 1728 | } 1729 | 1730 | var linkDensity = this._getLinkDensity(node); 1731 | var contentLength = this._getInnerText(node).length; 1732 | 1733 | var haveToRemove = 1734 | (img > 1 && p / img < 0.5 && !this._hasAncestorTag(node, "figure")) || 1735 | (!isList && li > p) || 1736 | (input > Math.floor(p/3)) || 1737 | (!isList && contentLength < 25 && (img === 0 || img > 2) && !this._hasAncestorTag(node, "figure")) || 1738 | (!isList && weight < 25 && linkDensity > 0.2) || 1739 | (weight >= 25 && linkDensity > 0.5) || 1740 | ((embedCount === 1 && contentLength < 75) || embedCount > 1); 1741 | return haveToRemove; 1742 | } 1743 | return false; 1744 | }); 1745 | }, 1746 | 1747 | /** 1748 | * Clean out elements that match the specified conditions 1749 | * 1750 | * @param Element 1751 | * @param Function determines whether a node should be removed 1752 | * @return void 1753 | **/ 1754 | _cleanMatchedNodes: function(e, filter) { 1755 | var endOfSearchMarkerNode = this._getNextNode(e, true); 1756 | var next = this._getNextNode(e); 1757 | while (next && next != endOfSearchMarkerNode) { 1758 | if (filter.call(this, next, next.className + " " + next.id)) { 1759 | next = this._removeAndGetNext(next); 1760 | } else { 1761 | next = this._getNextNode(next); 1762 | } 1763 | } 1764 | }, 1765 | 1766 | /** 1767 | * Clean out spurious headers from an Element. Checks things like classnames and link density. 1768 | * 1769 | * @param Element 1770 | * @return void 1771 | **/ 1772 | _cleanHeaders: function(e) { 1773 | for (var headerIndex = 1; headerIndex < 3; headerIndex += 1) { 1774 | this._removeNodes(e.getElementsByTagName("h" + headerIndex), function (header) { 1775 | return this._getClassWeight(header) < 0; 1776 | }); 1777 | } 1778 | }, 1779 | 1780 | _flagIsActive: function(flag) { 1781 | return (this._flags & flag) > 0; 1782 | }, 1783 | 1784 | _removeFlag: function(flag) { 1785 | this._flags = this._flags & ~flag; 1786 | }, 1787 | 1788 | _isProbablyVisible: function(node) { 1789 | return (!node.style || node.style.display != "none") 1790 | && !node.hasAttribute("hidden") 1791 | && (!node.hasAttribute("aria-hidden") || node.getAttribute("aria-hidden") != "true"); 1792 | }, 1793 | 1794 | /** 1795 | * Runs readability. 1796 | * 1797 | * Workflow: 1798 | * 1. Prep the document by removing script tags, css, etc. 1799 | * 2. Build readability's DOM tree. 1800 | * 3. Grab the article content from the current dom tree. 1801 | * 4. Replace the current DOM tree with the new one. 1802 | * 5. Read peacefully. 1803 | * 1804 | * @return void 1805 | **/ 1806 | parse: function () { 1807 | // Avoid parsing too large documents, as per configuration option 1808 | if (this._maxElemsToParse > 0) { 1809 | var numTags = this._doc.getElementsByTagName("*").length; 1810 | if (numTags > this._maxElemsToParse) { 1811 | throw new Error("Aborting parsing document; " + numTags + " elements found"); 1812 | } 1813 | } 1814 | 1815 | // Remove script tags from the document. 1816 | this._removeScripts(this._doc); 1817 | 1818 | this._prepDocument(); 1819 | 1820 | var metadata = this._getArticleMetadata(); 1821 | this._articleTitle = metadata.title; 1822 | 1823 | var articleContent = this._grabArticle(); 1824 | if (!articleContent) 1825 | return null; 1826 | 1827 | this.log("Grabbed: " + articleContent.innerHTML); 1828 | 1829 | this._postProcessContent(articleContent); 1830 | 1831 | // If we haven't found an excerpt in the article's metadata, use the article's 1832 | // first paragraph as the excerpt. This is used for displaying a preview of 1833 | // the article's content. 1834 | if (!metadata.excerpt) { 1835 | var paragraphs = articleContent.getElementsByTagName("p"); 1836 | if (paragraphs.length > 0) { 1837 | metadata.excerpt = paragraphs[0].textContent.trim(); 1838 | } 1839 | } 1840 | 1841 | var textContent = articleContent.textContent; 1842 | return { 1843 | title: this._articleTitle, 1844 | byline: metadata.byline || this._articleByline, 1845 | dir: this._articleDir, 1846 | content: articleContent.innerHTML, 1847 | textContent: textContent, 1848 | length: textContent.length, 1849 | excerpt: metadata.excerpt, 1850 | siteName: metadata.siteName || this._articleSiteName 1851 | }; 1852 | } 1853 | }; 1854 | 1855 | if (typeof module === "object") { 1856 | module.exports = Readability; 1857 | } 1858 | -------------------------------------------------------------------------------- /lib/web-clipper-message-dialog.js: -------------------------------------------------------------------------------- 1 | 'use babel' 2 | 3 | import * as React from 'react' 4 | import { CompositeDisposable } from 'event-kit' 5 | import { html2markdown } from 'inkdrop' 6 | import Readability from './Readability' 7 | import { models } from 'inkdrop' 8 | // import { actions } from 'inkdrop' 9 | const { Note } = models 10 | 11 | export default class WebClipperMessageDialog extends React.Component { 12 | dialog = { dismissDialog: () => null } 13 | state = { 14 | urlToClip: '', 15 | destBookId: null, 16 | formErrorMessage: null 17 | } 18 | 19 | componentDidMount() { 20 | // Events subscribed to in Inkdrop's system can be easily cleaned up with a CompositeDisposable 21 | this.subscriptions = new CompositeDisposable() 22 | 23 | // Register command that toggles this dialog 24 | this.subscriptions.add( 25 | inkdrop.commands.add(document.body, { 26 | 'web-clipper:clip-page': () => this.handleClipPageCommand() 27 | }) 28 | ) 29 | } 30 | 31 | componentWillUnmount() { 32 | this.subscriptions.dispose() 33 | } 34 | 35 | renderFormError() { 36 | if (this.state.formErrorMessage) { 37 | return ( 38 |
39 |

{this.state.formErrorMessage}

40 |
41 | ) 42 | } 43 | } 44 | 45 | render() { 46 | const { MessageDialog, NotebookPicker } = inkdrop.components.classes 47 | const buttons = [ 48 | { 49 | label: 'Cancel' 50 | }, 51 | { 52 | label: 'Clip', 53 | primary: true 54 | // FIXME: allow submit using Enter 55 | } 56 | ] 57 | 58 | return ( 59 | (this.dialog = d)} 61 | title="Markdown Web Clipper" 62 | buttons={buttons} 63 | onDismiss={this.handleDismissDialog} 64 | > 65 |
66 | {this.renderFormError()} 67 |
68 | 73 |
74 |
75 | 81 |
82 |
83 |
84 | ) 85 | } 86 | 87 | handleChangeBook = bookId => { 88 | this.setState({ 89 | destBookId: bookId 90 | }) 91 | } 92 | 93 | handleChangeUrl = e => { 94 | this.setState({ 95 | urlToClip: e.target.value 96 | }) 97 | } 98 | 99 | handleDismissDialog = (dialog, buttonIndex) => { 100 | if (buttonIndex === 1) { 101 | const { destBookId, urlToClip } = this.state 102 | this.setState({ formErrorMessage: null }) 103 | 104 | if (!destBookId) { 105 | this.setState({ 106 | formErrorMessage: 'Please select the destination notebook.' 107 | }) 108 | return false 109 | } 110 | 111 | // Check if the URL is valid 112 | try { 113 | new URL(urlToClip) 114 | } catch (err) { 115 | console.warn('Web Clipper: invalid URL ' + urlToClip) 116 | this.setState({ formErrorMessage: 'Please provide a valid URL.' }) 117 | return false 118 | } 119 | 120 | // Get the page HTML using Fetch 121 | fetch(urlToClip) 122 | .then(res => res.text()) 123 | .then(text => { 124 | // Construct a DOM with the page contents 125 | const dom = new DOMParser().parseFromString(text, 'text/html') 126 | 127 | // This is required to convert relative links to absolute links 128 | // as Readability uses dom.baseURI which cannot be modified directly. 129 | const base = dom.createElement('base') 130 | base.href = urlToClip 131 | dom.head.appendChild(base) 132 | 133 | // Strip the page to just the article contents using Readability 134 | const article = new Readability(dom).parse() 135 | 136 | // Convert the article HTML to Markdown 137 | let markdown = (0, html2markdown)(article.content) 138 | 139 | // Insert the source and date at the bottom 140 | markdown = `${markdown} 141 | 142 | --- 143 | 144 | Clipped from [${ 145 | new URL(urlToClip).host 146 | }](${urlToClip}) on ${new Date().toLocaleDateString()} 147 | ` 148 | const note = new Note({ 149 | title: article.title, 150 | body: markdown, 151 | bookId: destBookId 152 | }) 153 | 154 | note.save().then(doc => { 155 | // Open the newly created note 156 | inkdrop.commands.dispatch(document.body, 'core:open-note', { 157 | noteId: doc.id 158 | }) 159 | this.dialog.dismissDialog() 160 | }) 161 | }) 162 | .catch(() => { 163 | console.warn("Web Clipper: couldn't fetch URL " + urlToClip) 164 | this.setState({ formErrorMessage: "Couldn't clip this URL." }) 165 | }) 166 | 167 | return false 168 | } 169 | } 170 | 171 | handleClipPageCommand() { 172 | if (!this.dialog.isShown) { 173 | this.setState({ 174 | urlToClip: '', 175 | destBookId: null, 176 | formErrorMessage: null 177 | }) 178 | this.dialog.showDialog() 179 | } 180 | } 181 | } 182 | -------------------------------------------------------------------------------- /lib/web-clipper.js: -------------------------------------------------------------------------------- 1 | 'use babel' 2 | 3 | import WebClipperMessageDialog from './web-clipper-message-dialog' 4 | 5 | module.exports = { 6 | activate() { 7 | inkdrop.components.registerClass(WebClipperMessageDialog) 8 | inkdrop.layouts.addComponentToLayout('modal', 'WebClipperMessageDialog') 9 | }, 10 | 11 | deactivate() { 12 | inkdrop.layouts.removeComponentFromLayout( 13 | 'modal', 14 | 'WebClipperMessageDialog' 15 | ) 16 | inkdrop.components.deleteClass(WebClipperMessageDialog) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /menus/web-clipper.json: -------------------------------------------------------------------------------- 1 | { 2 | "menu": [ 3 | { 4 | "label": "Plugins", 5 | "submenu": [ 6 | { 7 | "label": "Clip Web Page...", 8 | "command": "web-clipper:clip-page" 9 | } 10 | ] 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web-clipper", 3 | "version": "1.1.1", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@babel/code-frame": { 8 | "version": "7.5.5", 9 | "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", 10 | "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", 11 | "dev": true, 12 | "requires": { 13 | "@babel/highlight": "^7.0.0" 14 | } 15 | }, 16 | "@babel/generator": { 17 | "version": "7.7.7", 18 | "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.7.7.tgz", 19 | "integrity": "sha512-/AOIBpHh/JU1l0ZFS4kiRCBnLi6OTHzh0RPk3h9isBxkkqELtQNFi1Vr/tiG9p1yfoUdKVwISuXWQR+hwwM4VQ==", 20 | "dev": true, 21 | "requires": { 22 | "@babel/types": "^7.7.4", 23 | "jsesc": "^2.5.1", 24 | "lodash": "^4.17.13", 25 | "source-map": "^0.5.0" 26 | } 27 | }, 28 | "@babel/helper-function-name": { 29 | "version": "7.7.4", 30 | "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.7.4.tgz", 31 | "integrity": "sha512-AnkGIdiBhEuiwdoMnKm7jfPfqItZhgRaZfMg1XX3bS25INOnLPjPG1Ppnajh8eqgt5kPJnfqrRHqFqmjKDZLzQ==", 32 | "dev": true, 33 | "requires": { 34 | "@babel/helper-get-function-arity": "^7.7.4", 35 | "@babel/template": "^7.7.4", 36 | "@babel/types": "^7.7.4" 37 | } 38 | }, 39 | "@babel/helper-get-function-arity": { 40 | "version": "7.7.4", 41 | "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.7.4.tgz", 42 | "integrity": "sha512-QTGKEdCkjgzgfJ3bAyRwF4yyT3pg+vDgan8DSivq1eS0gwi+KGKE5x8kRcbeFTb/673mkO5SN1IZfmCfA5o+EA==", 43 | "dev": true, 44 | "requires": { 45 | "@babel/types": "^7.7.4" 46 | } 47 | }, 48 | "@babel/helper-split-export-declaration": { 49 | "version": "7.7.4", 50 | "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.7.4.tgz", 51 | "integrity": "sha512-guAg1SXFcVr04Guk9eq0S4/rWS++sbmyqosJzVs8+1fH5NI+ZcmkaSkc7dmtAFbHFva6yRJnjW3yAcGxjueDug==", 52 | "dev": true, 53 | "requires": { 54 | "@babel/types": "^7.7.4" 55 | } 56 | }, 57 | "@babel/highlight": { 58 | "version": "7.5.0", 59 | "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", 60 | "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", 61 | "dev": true, 62 | "requires": { 63 | "chalk": "^2.0.0", 64 | "esutils": "^2.0.2", 65 | "js-tokens": "^4.0.0" 66 | } 67 | }, 68 | "@babel/parser": { 69 | "version": "7.7.7", 70 | "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.7.7.tgz", 71 | "integrity": "sha512-WtTZMZAZLbeymhkd/sEaPD8IQyGAhmuTuvTzLiCFM7iXiVdY0gc0IaI+cW0fh1BnSMbJSzXX6/fHllgHKwHhXw==", 72 | "dev": true 73 | }, 74 | "@babel/template": { 75 | "version": "7.7.4", 76 | "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.7.4.tgz", 77 | "integrity": "sha512-qUzihgVPguAzXCK7WXw8pqs6cEwi54s3E+HrejlkuWO6ivMKx9hZl3Y2fSXp9i5HgyWmj7RKP+ulaYnKM4yYxw==", 78 | "dev": true, 79 | "requires": { 80 | "@babel/code-frame": "^7.0.0", 81 | "@babel/parser": "^7.7.4", 82 | "@babel/types": "^7.7.4" 83 | } 84 | }, 85 | "@babel/traverse": { 86 | "version": "7.7.4", 87 | "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.7.4.tgz", 88 | "integrity": "sha512-P1L58hQyupn8+ezVA2z5KBm4/Zr4lCC8dwKCMYzsa5jFMDMQAzaBNy9W5VjB+KAmBjb40U7a/H6ao+Xo+9saIw==", 89 | "dev": true, 90 | "requires": { 91 | "@babel/code-frame": "^7.5.5", 92 | "@babel/generator": "^7.7.4", 93 | "@babel/helper-function-name": "^7.7.4", 94 | "@babel/helper-split-export-declaration": "^7.7.4", 95 | "@babel/parser": "^7.7.4", 96 | "@babel/types": "^7.7.4", 97 | "debug": "^4.1.0", 98 | "globals": "^11.1.0", 99 | "lodash": "^4.17.13" 100 | } 101 | }, 102 | "@babel/types": { 103 | "version": "7.7.4", 104 | "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.7.4.tgz", 105 | "integrity": "sha512-cz5Ji23KCi4T+YIE/BolWosrJuSmoZeN1EFnRtBwF+KKLi8GG/Z2c2hOJJeCXPk4mwk4QFvTmwIodJowXgttRA==", 106 | "dev": true, 107 | "requires": { 108 | "esutils": "^2.0.2", 109 | "lodash": "^4.17.13", 110 | "to-fast-properties": "^2.0.0" 111 | } 112 | }, 113 | "acorn": { 114 | "version": "7.1.0", 115 | "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz", 116 | "integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==", 117 | "dev": true 118 | }, 119 | "acorn-jsx": { 120 | "version": "5.1.0", 121 | "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.1.0.tgz", 122 | "integrity": "sha512-tMUqwBWfLFbJbizRmEcWSLw6HnFzfdJs2sOJEOwwtVPMoH/0Ay+E703oZz78VSXZiiDcZrQ5XKjPIUQixhmgVw==", 123 | "dev": true 124 | }, 125 | "ajv": { 126 | "version": "6.10.2", 127 | "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", 128 | "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", 129 | "dev": true, 130 | "requires": { 131 | "fast-deep-equal": "^2.0.1", 132 | "fast-json-stable-stringify": "^2.0.0", 133 | "json-schema-traverse": "^0.4.1", 134 | "uri-js": "^4.2.2" 135 | } 136 | }, 137 | "ansi-escapes": { 138 | "version": "4.3.0", 139 | "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.0.tgz", 140 | "integrity": "sha512-EiYhwo0v255HUL6eDyuLrXEkTi7WwVCLAw+SeOQ7M7qdun1z1pum4DEm/nuqIVbPvi9RPPc9k9LbyBv6H0DwVg==", 141 | "dev": true, 142 | "requires": { 143 | "type-fest": "^0.8.1" 144 | } 145 | }, 146 | "ansi-regex": { 147 | "version": "5.0.0", 148 | "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", 149 | "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", 150 | "dev": true 151 | }, 152 | "ansi-styles": { 153 | "version": "3.2.1", 154 | "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", 155 | "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", 156 | "dev": true, 157 | "requires": { 158 | "color-convert": "^1.9.0" 159 | } 160 | }, 161 | "argparse": { 162 | "version": "1.0.10", 163 | "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", 164 | "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", 165 | "dev": true, 166 | "requires": { 167 | "sprintf-js": "~1.0.2" 168 | } 169 | }, 170 | "array-includes": { 171 | "version": "3.1.0", 172 | "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.0.tgz", 173 | "integrity": "sha512-ONOEQoKrvXPKk7Su92Co0YMqYO32FfqJTzkKU9u2UpIXyYZIzLSvpdg4AwvSw4mSUW0czu6inK+zby6Oj6gDjQ==", 174 | "dev": true, 175 | "requires": { 176 | "define-properties": "^1.1.3", 177 | "es-abstract": "^1.17.0-next.0" 178 | } 179 | }, 180 | "astral-regex": { 181 | "version": "1.0.0", 182 | "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", 183 | "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", 184 | "dev": true 185 | }, 186 | "babel-eslint": { 187 | "version": "10.0.3", 188 | "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.0.3.tgz", 189 | "integrity": "sha512-z3U7eMY6r/3f3/JB9mTsLjyxrv0Yb1zb8PCWCLpguxfCzBIZUwy23R1t/XKewP+8mEN2Ck8Dtr4q20z6ce6SoA==", 190 | "dev": true, 191 | "requires": { 192 | "@babel/code-frame": "^7.0.0", 193 | "@babel/parser": "^7.0.0", 194 | "@babel/traverse": "^7.0.0", 195 | "@babel/types": "^7.0.0", 196 | "eslint-visitor-keys": "^1.0.0", 197 | "resolve": "^1.12.0" 198 | } 199 | }, 200 | "balanced-match": { 201 | "version": "1.0.0", 202 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", 203 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", 204 | "dev": true 205 | }, 206 | "brace-expansion": { 207 | "version": "1.1.11", 208 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 209 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 210 | "dev": true, 211 | "requires": { 212 | "balanced-match": "^1.0.0", 213 | "concat-map": "0.0.1" 214 | } 215 | }, 216 | "callsites": { 217 | "version": "3.1.0", 218 | "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", 219 | "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", 220 | "dev": true 221 | }, 222 | "chalk": { 223 | "version": "2.4.2", 224 | "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", 225 | "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", 226 | "dev": true, 227 | "requires": { 228 | "ansi-styles": "^3.2.1", 229 | "escape-string-regexp": "^1.0.5", 230 | "supports-color": "^5.3.0" 231 | } 232 | }, 233 | "chardet": { 234 | "version": "0.7.0", 235 | "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", 236 | "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", 237 | "dev": true 238 | }, 239 | "cli-cursor": { 240 | "version": "3.1.0", 241 | "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", 242 | "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", 243 | "dev": true, 244 | "requires": { 245 | "restore-cursor": "^3.1.0" 246 | } 247 | }, 248 | "cli-width": { 249 | "version": "2.2.0", 250 | "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", 251 | "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", 252 | "dev": true 253 | }, 254 | "color-convert": { 255 | "version": "1.9.3", 256 | "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", 257 | "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", 258 | "dev": true, 259 | "requires": { 260 | "color-name": "1.1.3" 261 | } 262 | }, 263 | "color-name": { 264 | "version": "1.1.3", 265 | "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", 266 | "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", 267 | "dev": true 268 | }, 269 | "concat-map": { 270 | "version": "0.0.1", 271 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 272 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", 273 | "dev": true 274 | }, 275 | "core-js": { 276 | "version": "2.6.11", 277 | "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.11.tgz", 278 | "integrity": "sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg==" 279 | }, 280 | "cross-spawn": { 281 | "version": "6.0.5", 282 | "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", 283 | "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", 284 | "dev": true, 285 | "requires": { 286 | "nice-try": "^1.0.4", 287 | "path-key": "^2.0.1", 288 | "semver": "^5.5.0", 289 | "shebang-command": "^1.2.0", 290 | "which": "^1.2.9" 291 | }, 292 | "dependencies": { 293 | "semver": { 294 | "version": "5.7.1", 295 | "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", 296 | "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", 297 | "dev": true 298 | } 299 | } 300 | }, 301 | "debug": { 302 | "version": "4.1.1", 303 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", 304 | "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", 305 | "dev": true, 306 | "requires": { 307 | "ms": "^2.1.1" 308 | } 309 | }, 310 | "deep-is": { 311 | "version": "0.1.3", 312 | "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", 313 | "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", 314 | "dev": true 315 | }, 316 | "define-properties": { 317 | "version": "1.1.3", 318 | "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", 319 | "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", 320 | "dev": true, 321 | "requires": { 322 | "object-keys": "^1.0.12" 323 | } 324 | }, 325 | "doctrine": { 326 | "version": "3.0.0", 327 | "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", 328 | "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", 329 | "dev": true, 330 | "requires": { 331 | "esutils": "^2.0.2" 332 | } 333 | }, 334 | "emoji-regex": { 335 | "version": "8.0.0", 336 | "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", 337 | "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", 338 | "dev": true 339 | }, 340 | "es-abstract": { 341 | "version": "1.17.0-next.1", 342 | "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.0-next.1.tgz", 343 | "integrity": "sha512-7MmGr03N7Rnuid6+wyhD9sHNE2n4tFSwExnU2lQl3lIo2ShXWGePY80zYaoMOmILWv57H0amMjZGHNzzGG70Rw==", 344 | "dev": true, 345 | "requires": { 346 | "es-to-primitive": "^1.2.1", 347 | "function-bind": "^1.1.1", 348 | "has": "^1.0.3", 349 | "has-symbols": "^1.0.1", 350 | "is-callable": "^1.1.4", 351 | "is-regex": "^1.0.4", 352 | "object-inspect": "^1.7.0", 353 | "object-keys": "^1.1.1", 354 | "object.assign": "^4.1.0", 355 | "string.prototype.trimleft": "^2.1.0", 356 | "string.prototype.trimright": "^2.1.0" 357 | } 358 | }, 359 | "es-to-primitive": { 360 | "version": "1.2.1", 361 | "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", 362 | "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", 363 | "dev": true, 364 | "requires": { 365 | "is-callable": "^1.1.4", 366 | "is-date-object": "^1.0.1", 367 | "is-symbol": "^1.0.2" 368 | } 369 | }, 370 | "escape-string-regexp": { 371 | "version": "1.0.5", 372 | "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", 373 | "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", 374 | "dev": true 375 | }, 376 | "eslint": { 377 | "version": "6.7.2", 378 | "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.7.2.tgz", 379 | "integrity": "sha512-qMlSWJaCSxDFr8fBPvJM9kJwbazrhNcBU3+DszDW1OlEwKBBRWsJc7NJFelvwQpanHCR14cOLD41x8Eqvo3Nng==", 380 | "dev": true, 381 | "requires": { 382 | "@babel/code-frame": "^7.0.0", 383 | "ajv": "^6.10.0", 384 | "chalk": "^2.1.0", 385 | "cross-spawn": "^6.0.5", 386 | "debug": "^4.0.1", 387 | "doctrine": "^3.0.0", 388 | "eslint-scope": "^5.0.0", 389 | "eslint-utils": "^1.4.3", 390 | "eslint-visitor-keys": "^1.1.0", 391 | "espree": "^6.1.2", 392 | "esquery": "^1.0.1", 393 | "esutils": "^2.0.2", 394 | "file-entry-cache": "^5.0.1", 395 | "functional-red-black-tree": "^1.0.1", 396 | "glob-parent": "^5.0.0", 397 | "globals": "^12.1.0", 398 | "ignore": "^4.0.6", 399 | "import-fresh": "^3.0.0", 400 | "imurmurhash": "^0.1.4", 401 | "inquirer": "^7.0.0", 402 | "is-glob": "^4.0.0", 403 | "js-yaml": "^3.13.1", 404 | "json-stable-stringify-without-jsonify": "^1.0.1", 405 | "levn": "^0.3.0", 406 | "lodash": "^4.17.14", 407 | "minimatch": "^3.0.4", 408 | "mkdirp": "^0.5.1", 409 | "natural-compare": "^1.4.0", 410 | "optionator": "^0.8.3", 411 | "progress": "^2.0.0", 412 | "regexpp": "^2.0.1", 413 | "semver": "^6.1.2", 414 | "strip-ansi": "^5.2.0", 415 | "strip-json-comments": "^3.0.1", 416 | "table": "^5.2.3", 417 | "text-table": "^0.2.0", 418 | "v8-compile-cache": "^2.0.3" 419 | }, 420 | "dependencies": { 421 | "globals": { 422 | "version": "12.3.0", 423 | "resolved": "https://registry.npmjs.org/globals/-/globals-12.3.0.tgz", 424 | "integrity": "sha512-wAfjdLgFsPZsklLJvOBUBmzYE8/CwhEqSBEMRXA3qxIiNtyqvjYurAtIfDh6chlEPUfmTY3MnZh5Hfh4q0UlIw==", 425 | "dev": true, 426 | "requires": { 427 | "type-fest": "^0.8.1" 428 | } 429 | } 430 | } 431 | }, 432 | "eslint-config-prettier": { 433 | "version": "6.7.0", 434 | "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.7.0.tgz", 435 | "integrity": "sha512-FamQVKM3jjUVwhG4hEMnbtsq7xOIDm+SY5iBPfR8gKsJoAB2IQnNF+bk1+8Fy44Nq7PPJaLvkRxILYdJWoguKQ==", 436 | "dev": true, 437 | "requires": { 438 | "get-stdin": "^6.0.0" 439 | } 440 | }, 441 | "eslint-plugin-eslint-plugin": { 442 | "version": "2.1.0", 443 | "resolved": "https://registry.npmjs.org/eslint-plugin-eslint-plugin/-/eslint-plugin-eslint-plugin-2.1.0.tgz", 444 | "integrity": "sha512-kT3A/ZJftt28gbl/Cv04qezb/NQ1dwYIbi8lyf806XMxkus7DvOVCLIfTXMrorp322Pnoez7+zabXH29tADIDg==", 445 | "dev": true 446 | }, 447 | "eslint-plugin-prettier": { 448 | "version": "3.1.2", 449 | "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.2.tgz", 450 | "integrity": "sha512-GlolCC9y3XZfv3RQfwGew7NnuFDKsfI4lbvRK+PIIo23SFH+LemGs4cKwzAaRa+Mdb+lQO/STaIayno8T5sJJA==", 451 | "dev": true, 452 | "requires": { 453 | "prettier-linter-helpers": "^1.0.0" 454 | } 455 | }, 456 | "eslint-plugin-react": { 457 | "version": "7.17.0", 458 | "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.17.0.tgz", 459 | "integrity": "sha512-ODB7yg6lxhBVMeiH1c7E95FLD4E/TwmFjltiU+ethv7KPdCwgiFuOZg9zNRHyufStTDLl/dEFqI2Q1VPmCd78A==", 460 | "dev": true, 461 | "requires": { 462 | "array-includes": "^3.0.3", 463 | "doctrine": "^2.1.0", 464 | "eslint-plugin-eslint-plugin": "^2.1.0", 465 | "has": "^1.0.3", 466 | "jsx-ast-utils": "^2.2.3", 467 | "object.entries": "^1.1.0", 468 | "object.fromentries": "^2.0.1", 469 | "object.values": "^1.1.0", 470 | "prop-types": "^15.7.2", 471 | "resolve": "^1.13.1" 472 | }, 473 | "dependencies": { 474 | "doctrine": { 475 | "version": "2.1.0", 476 | "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", 477 | "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", 478 | "dev": true, 479 | "requires": { 480 | "esutils": "^2.0.2" 481 | } 482 | } 483 | } 484 | }, 485 | "eslint-scope": { 486 | "version": "5.0.0", 487 | "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", 488 | "integrity": "sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw==", 489 | "dev": true, 490 | "requires": { 491 | "esrecurse": "^4.1.0", 492 | "estraverse": "^4.1.1" 493 | } 494 | }, 495 | "eslint-utils": { 496 | "version": "1.4.3", 497 | "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz", 498 | "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==", 499 | "dev": true, 500 | "requires": { 501 | "eslint-visitor-keys": "^1.1.0" 502 | } 503 | }, 504 | "eslint-visitor-keys": { 505 | "version": "1.1.0", 506 | "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz", 507 | "integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==", 508 | "dev": true 509 | }, 510 | "espree": { 511 | "version": "6.1.2", 512 | "resolved": "https://registry.npmjs.org/espree/-/espree-6.1.2.tgz", 513 | "integrity": "sha512-2iUPuuPP+yW1PZaMSDM9eyVf8D5P0Hi8h83YtZ5bPc/zHYjII5khoixIUTMO794NOY8F/ThF1Bo8ncZILarUTA==", 514 | "dev": true, 515 | "requires": { 516 | "acorn": "^7.1.0", 517 | "acorn-jsx": "^5.1.0", 518 | "eslint-visitor-keys": "^1.1.0" 519 | } 520 | }, 521 | "esprima": { 522 | "version": "4.0.1", 523 | "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", 524 | "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", 525 | "dev": true 526 | }, 527 | "esquery": { 528 | "version": "1.0.1", 529 | "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", 530 | "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", 531 | "dev": true, 532 | "requires": { 533 | "estraverse": "^4.0.0" 534 | } 535 | }, 536 | "esrecurse": { 537 | "version": "4.2.1", 538 | "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", 539 | "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", 540 | "dev": true, 541 | "requires": { 542 | "estraverse": "^4.1.0" 543 | } 544 | }, 545 | "estraverse": { 546 | "version": "4.3.0", 547 | "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", 548 | "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", 549 | "dev": true 550 | }, 551 | "esutils": { 552 | "version": "2.0.3", 553 | "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", 554 | "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", 555 | "dev": true 556 | }, 557 | "external-editor": { 558 | "version": "3.1.0", 559 | "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", 560 | "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", 561 | "dev": true, 562 | "requires": { 563 | "chardet": "^0.7.0", 564 | "iconv-lite": "^0.4.24", 565 | "tmp": "^0.0.33" 566 | } 567 | }, 568 | "fast-deep-equal": { 569 | "version": "2.0.1", 570 | "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", 571 | "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", 572 | "dev": true 573 | }, 574 | "fast-diff": { 575 | "version": "1.2.0", 576 | "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", 577 | "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", 578 | "dev": true 579 | }, 580 | "fast-json-stable-stringify": { 581 | "version": "2.1.0", 582 | "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", 583 | "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", 584 | "dev": true 585 | }, 586 | "fast-levenshtein": { 587 | "version": "2.0.6", 588 | "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", 589 | "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", 590 | "dev": true 591 | }, 592 | "figures": { 593 | "version": "3.1.0", 594 | "resolved": "https://registry.npmjs.org/figures/-/figures-3.1.0.tgz", 595 | "integrity": "sha512-ravh8VRXqHuMvZt/d8GblBeqDMkdJMBdv/2KntFH+ra5MXkO7nxNKpzQ3n6QD/2da1kH0aWmNISdvhM7gl2gVg==", 596 | "dev": true, 597 | "requires": { 598 | "escape-string-regexp": "^1.0.5" 599 | } 600 | }, 601 | "file-entry-cache": { 602 | "version": "5.0.1", 603 | "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", 604 | "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", 605 | "dev": true, 606 | "requires": { 607 | "flat-cache": "^2.0.1" 608 | } 609 | }, 610 | "flat-cache": { 611 | "version": "2.0.1", 612 | "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", 613 | "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", 614 | "dev": true, 615 | "requires": { 616 | "flatted": "^2.0.0", 617 | "rimraf": "2.6.3", 618 | "write": "1.0.3" 619 | } 620 | }, 621 | "flatted": { 622 | "version": "2.0.1", 623 | "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.1.tgz", 624 | "integrity": "sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==", 625 | "dev": true 626 | }, 627 | "fs.realpath": { 628 | "version": "1.0.0", 629 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 630 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", 631 | "dev": true 632 | }, 633 | "function-bind": { 634 | "version": "1.1.1", 635 | "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", 636 | "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", 637 | "dev": true 638 | }, 639 | "functional-red-black-tree": { 640 | "version": "1.0.1", 641 | "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", 642 | "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", 643 | "dev": true 644 | }, 645 | "get-stdin": { 646 | "version": "6.0.0", 647 | "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", 648 | "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==", 649 | "dev": true 650 | }, 651 | "glob": { 652 | "version": "7.1.6", 653 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", 654 | "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", 655 | "dev": true, 656 | "requires": { 657 | "fs.realpath": "^1.0.0", 658 | "inflight": "^1.0.4", 659 | "inherits": "2", 660 | "minimatch": "^3.0.4", 661 | "once": "^1.3.0", 662 | "path-is-absolute": "^1.0.0" 663 | } 664 | }, 665 | "glob-parent": { 666 | "version": "5.1.0", 667 | "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", 668 | "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", 669 | "dev": true, 670 | "requires": { 671 | "is-glob": "^4.0.1" 672 | } 673 | }, 674 | "globals": { 675 | "version": "11.12.0", 676 | "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", 677 | "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", 678 | "dev": true 679 | }, 680 | "has": { 681 | "version": "1.0.3", 682 | "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", 683 | "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", 684 | "dev": true, 685 | "requires": { 686 | "function-bind": "^1.1.1" 687 | } 688 | }, 689 | "has-flag": { 690 | "version": "3.0.0", 691 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", 692 | "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", 693 | "dev": true 694 | }, 695 | "has-symbols": { 696 | "version": "1.0.1", 697 | "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", 698 | "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", 699 | "dev": true 700 | }, 701 | "iconv-lite": { 702 | "version": "0.4.24", 703 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", 704 | "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", 705 | "dev": true, 706 | "requires": { 707 | "safer-buffer": ">= 2.1.2 < 3" 708 | } 709 | }, 710 | "ignore": { 711 | "version": "4.0.6", 712 | "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", 713 | "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", 714 | "dev": true 715 | }, 716 | "import-fresh": { 717 | "version": "3.2.1", 718 | "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz", 719 | "integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==", 720 | "dev": true, 721 | "requires": { 722 | "parent-module": "^1.0.0", 723 | "resolve-from": "^4.0.0" 724 | } 725 | }, 726 | "imurmurhash": { 727 | "version": "0.1.4", 728 | "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", 729 | "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", 730 | "dev": true 731 | }, 732 | "inflight": { 733 | "version": "1.0.6", 734 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 735 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", 736 | "dev": true, 737 | "requires": { 738 | "once": "^1.3.0", 739 | "wrappy": "1" 740 | } 741 | }, 742 | "inherits": { 743 | "version": "2.0.4", 744 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 745 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", 746 | "dev": true 747 | }, 748 | "inquirer": { 749 | "version": "7.0.1", 750 | "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.1.tgz", 751 | "integrity": "sha512-V1FFQ3TIO15det8PijPLFR9M9baSlnRs9nL7zWu1MNVA2T9YVl9ZbrHJhYs7e9X8jeMZ3lr2JH/rdHFgNCBdYw==", 752 | "dev": true, 753 | "requires": { 754 | "ansi-escapes": "^4.2.1", 755 | "chalk": "^2.4.2", 756 | "cli-cursor": "^3.1.0", 757 | "cli-width": "^2.0.0", 758 | "external-editor": "^3.0.3", 759 | "figures": "^3.0.0", 760 | "lodash": "^4.17.15", 761 | "mute-stream": "0.0.8", 762 | "run-async": "^2.2.0", 763 | "rxjs": "^6.5.3", 764 | "string-width": "^4.1.0", 765 | "strip-ansi": "^5.1.0", 766 | "through": "^2.3.6" 767 | } 768 | }, 769 | "is-callable": { 770 | "version": "1.1.4", 771 | "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", 772 | "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", 773 | "dev": true 774 | }, 775 | "is-date-object": { 776 | "version": "1.0.2", 777 | "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", 778 | "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", 779 | "dev": true 780 | }, 781 | "is-extglob": { 782 | "version": "2.1.1", 783 | "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", 784 | "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", 785 | "dev": true 786 | }, 787 | "is-fullwidth-code-point": { 788 | "version": "3.0.0", 789 | "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", 790 | "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", 791 | "dev": true 792 | }, 793 | "is-glob": { 794 | "version": "4.0.1", 795 | "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", 796 | "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", 797 | "dev": true, 798 | "requires": { 799 | "is-extglob": "^2.1.1" 800 | } 801 | }, 802 | "is-promise": { 803 | "version": "2.1.0", 804 | "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", 805 | "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", 806 | "dev": true 807 | }, 808 | "is-regex": { 809 | "version": "1.0.5", 810 | "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", 811 | "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", 812 | "dev": true, 813 | "requires": { 814 | "has": "^1.0.3" 815 | } 816 | }, 817 | "is-symbol": { 818 | "version": "1.0.3", 819 | "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", 820 | "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", 821 | "dev": true, 822 | "requires": { 823 | "has-symbols": "^1.0.1" 824 | } 825 | }, 826 | "isexe": { 827 | "version": "2.0.0", 828 | "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", 829 | "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", 830 | "dev": true 831 | }, 832 | "js-tokens": { 833 | "version": "4.0.0", 834 | "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", 835 | "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", 836 | "dev": true 837 | }, 838 | "js-yaml": { 839 | "version": "3.13.1", 840 | "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", 841 | "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", 842 | "dev": true, 843 | "requires": { 844 | "argparse": "^1.0.7", 845 | "esprima": "^4.0.0" 846 | } 847 | }, 848 | "jsesc": { 849 | "version": "2.5.2", 850 | "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", 851 | "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", 852 | "dev": true 853 | }, 854 | "json-schema-traverse": { 855 | "version": "0.4.1", 856 | "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", 857 | "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", 858 | "dev": true 859 | }, 860 | "json-stable-stringify-without-jsonify": { 861 | "version": "1.0.1", 862 | "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", 863 | "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", 864 | "dev": true 865 | }, 866 | "jsx-ast-utils": { 867 | "version": "2.2.3", 868 | "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-2.2.3.tgz", 869 | "integrity": "sha512-EdIHFMm+1BPynpKOpdPqiOsvnIrInRGJD7bzPZdPkjitQEqpdpUuFpq4T0npZFKTiB3RhWFdGN+oqOJIdhDhQA==", 870 | "dev": true, 871 | "requires": { 872 | "array-includes": "^3.0.3", 873 | "object.assign": "^4.1.0" 874 | } 875 | }, 876 | "levn": { 877 | "version": "0.3.0", 878 | "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", 879 | "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", 880 | "dev": true, 881 | "requires": { 882 | "prelude-ls": "~1.1.2", 883 | "type-check": "~0.3.2" 884 | } 885 | }, 886 | "lodash": { 887 | "version": "4.17.15", 888 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", 889 | "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", 890 | "dev": true 891 | }, 892 | "loose-envify": { 893 | "version": "1.4.0", 894 | "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", 895 | "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", 896 | "dev": true, 897 | "requires": { 898 | "js-tokens": "^3.0.0 || ^4.0.0" 899 | } 900 | }, 901 | "mimic-fn": { 902 | "version": "2.1.0", 903 | "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", 904 | "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", 905 | "dev": true 906 | }, 907 | "minimatch": { 908 | "version": "3.0.4", 909 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 910 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 911 | "dev": true, 912 | "requires": { 913 | "brace-expansion": "^1.1.7" 914 | } 915 | }, 916 | "minimist": { 917 | "version": "0.0.8", 918 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", 919 | "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", 920 | "dev": true 921 | }, 922 | "mkdirp": { 923 | "version": "0.5.1", 924 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", 925 | "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", 926 | "dev": true, 927 | "requires": { 928 | "minimist": "0.0.8" 929 | } 930 | }, 931 | "ms": { 932 | "version": "2.1.2", 933 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 934 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", 935 | "dev": true 936 | }, 937 | "mute-stream": { 938 | "version": "0.0.8", 939 | "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", 940 | "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", 941 | "dev": true 942 | }, 943 | "natural-compare": { 944 | "version": "1.4.0", 945 | "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", 946 | "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", 947 | "dev": true 948 | }, 949 | "nice-try": { 950 | "version": "1.0.5", 951 | "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", 952 | "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", 953 | "dev": true 954 | }, 955 | "object-assign": { 956 | "version": "4.1.1", 957 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 958 | "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", 959 | "dev": true 960 | }, 961 | "object-inspect": { 962 | "version": "1.7.0", 963 | "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", 964 | "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", 965 | "dev": true 966 | }, 967 | "object-keys": { 968 | "version": "1.1.1", 969 | "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", 970 | "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", 971 | "dev": true 972 | }, 973 | "object.assign": { 974 | "version": "4.1.0", 975 | "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", 976 | "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", 977 | "dev": true, 978 | "requires": { 979 | "define-properties": "^1.1.2", 980 | "function-bind": "^1.1.1", 981 | "has-symbols": "^1.0.0", 982 | "object-keys": "^1.0.11" 983 | } 984 | }, 985 | "object.entries": { 986 | "version": "1.1.1", 987 | "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.1.tgz", 988 | "integrity": "sha512-ilqR7BgdyZetJutmDPfXCDffGa0/Yzl2ivVNpbx/g4UeWrCdRnFDUBrKJGLhGieRHDATnyZXWBeCb29k9CJysQ==", 989 | "dev": true, 990 | "requires": { 991 | "define-properties": "^1.1.3", 992 | "es-abstract": "^1.17.0-next.1", 993 | "function-bind": "^1.1.1", 994 | "has": "^1.0.3" 995 | } 996 | }, 997 | "object.fromentries": { 998 | "version": "2.0.2", 999 | "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.2.tgz", 1000 | "integrity": "sha512-r3ZiBH7MQppDJVLx6fhD618GKNG40CZYH9wgwdhKxBDDbQgjeWGGd4AtkZad84d291YxvWe7bJGuE65Anh0dxQ==", 1001 | "dev": true, 1002 | "requires": { 1003 | "define-properties": "^1.1.3", 1004 | "es-abstract": "^1.17.0-next.1", 1005 | "function-bind": "^1.1.1", 1006 | "has": "^1.0.3" 1007 | } 1008 | }, 1009 | "object.values": { 1010 | "version": "1.1.1", 1011 | "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.1.tgz", 1012 | "integrity": "sha512-WTa54g2K8iu0kmS/us18jEmdv1a4Wi//BZ/DTVYEcH0XhLM5NYdpDHja3gt57VrZLcNAO2WGA+KpWsDBaHt6eA==", 1013 | "dev": true, 1014 | "requires": { 1015 | "define-properties": "^1.1.3", 1016 | "es-abstract": "^1.17.0-next.1", 1017 | "function-bind": "^1.1.1", 1018 | "has": "^1.0.3" 1019 | } 1020 | }, 1021 | "once": { 1022 | "version": "1.4.0", 1023 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 1024 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 1025 | "dev": true, 1026 | "requires": { 1027 | "wrappy": "1" 1028 | } 1029 | }, 1030 | "onetime": { 1031 | "version": "5.1.0", 1032 | "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz", 1033 | "integrity": "sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==", 1034 | "dev": true, 1035 | "requires": { 1036 | "mimic-fn": "^2.1.0" 1037 | } 1038 | }, 1039 | "optionator": { 1040 | "version": "0.8.3", 1041 | "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", 1042 | "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", 1043 | "dev": true, 1044 | "requires": { 1045 | "deep-is": "~0.1.3", 1046 | "fast-levenshtein": "~2.0.6", 1047 | "levn": "~0.3.0", 1048 | "prelude-ls": "~1.1.2", 1049 | "type-check": "~0.3.2", 1050 | "word-wrap": "~1.2.3" 1051 | } 1052 | }, 1053 | "os-tmpdir": { 1054 | "version": "1.0.2", 1055 | "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", 1056 | "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", 1057 | "dev": true 1058 | }, 1059 | "parent-module": { 1060 | "version": "1.0.1", 1061 | "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", 1062 | "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", 1063 | "dev": true, 1064 | "requires": { 1065 | "callsites": "^3.0.0" 1066 | } 1067 | }, 1068 | "path-is-absolute": { 1069 | "version": "1.0.1", 1070 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 1071 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", 1072 | "dev": true 1073 | }, 1074 | "path-key": { 1075 | "version": "2.0.1", 1076 | "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", 1077 | "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", 1078 | "dev": true 1079 | }, 1080 | "path-parse": { 1081 | "version": "1.0.6", 1082 | "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", 1083 | "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", 1084 | "dev": true 1085 | }, 1086 | "prelude-ls": { 1087 | "version": "1.1.2", 1088 | "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", 1089 | "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", 1090 | "dev": true 1091 | }, 1092 | "prettier": { 1093 | "version": "1.19.1", 1094 | "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", 1095 | "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", 1096 | "dev": true 1097 | }, 1098 | "prettier-linter-helpers": { 1099 | "version": "1.0.0", 1100 | "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", 1101 | "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", 1102 | "dev": true, 1103 | "requires": { 1104 | "fast-diff": "^1.1.2" 1105 | } 1106 | }, 1107 | "progress": { 1108 | "version": "2.0.3", 1109 | "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", 1110 | "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", 1111 | "dev": true 1112 | }, 1113 | "prop-types": { 1114 | "version": "15.7.2", 1115 | "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz", 1116 | "integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==", 1117 | "dev": true, 1118 | "requires": { 1119 | "loose-envify": "^1.4.0", 1120 | "object-assign": "^4.1.1", 1121 | "react-is": "^16.8.1" 1122 | } 1123 | }, 1124 | "punycode": { 1125 | "version": "2.1.1", 1126 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", 1127 | "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", 1128 | "dev": true 1129 | }, 1130 | "react-is": { 1131 | "version": "16.12.0", 1132 | "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.12.0.tgz", 1133 | "integrity": "sha512-rPCkf/mWBtKc97aLL9/txD8DZdemK0vkA3JMLShjlJB3Pj3s+lpf1KaBzMfQrAmhMQB0n1cU/SUGgKKBCe837Q==", 1134 | "dev": true 1135 | }, 1136 | "regexpp": { 1137 | "version": "2.0.1", 1138 | "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", 1139 | "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", 1140 | "dev": true 1141 | }, 1142 | "resolve": { 1143 | "version": "1.14.1", 1144 | "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.14.1.tgz", 1145 | "integrity": "sha512-fn5Wobh4cxbLzuHaE+nphztHy43/b++4M6SsGFC2gB8uYwf0C8LcarfCz1un7UTW8OFQg9iNjZ4xpcFVGebDPg==", 1146 | "dev": true, 1147 | "requires": { 1148 | "path-parse": "^1.0.6" 1149 | } 1150 | }, 1151 | "resolve-from": { 1152 | "version": "4.0.0", 1153 | "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", 1154 | "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", 1155 | "dev": true 1156 | }, 1157 | "restore-cursor": { 1158 | "version": "3.1.0", 1159 | "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", 1160 | "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", 1161 | "dev": true, 1162 | "requires": { 1163 | "onetime": "^5.1.0", 1164 | "signal-exit": "^3.0.2" 1165 | } 1166 | }, 1167 | "rimraf": { 1168 | "version": "2.6.3", 1169 | "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", 1170 | "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", 1171 | "dev": true, 1172 | "requires": { 1173 | "glob": "^7.1.3" 1174 | } 1175 | }, 1176 | "run-async": { 1177 | "version": "2.3.0", 1178 | "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", 1179 | "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", 1180 | "dev": true, 1181 | "requires": { 1182 | "is-promise": "^2.1.0" 1183 | } 1184 | }, 1185 | "rxjs": { 1186 | "version": "6.5.3", 1187 | "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.3.tgz", 1188 | "integrity": "sha512-wuYsAYYFdWTAnAaPoKGNhfpWwKZbJW+HgAJ+mImp+Epl7BG8oNWBCTyRM8gba9k4lk8BgWdoYm21Mo/RYhhbgA==", 1189 | "dev": true, 1190 | "requires": { 1191 | "tslib": "^1.9.0" 1192 | } 1193 | }, 1194 | "safer-buffer": { 1195 | "version": "2.1.2", 1196 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", 1197 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", 1198 | "dev": true 1199 | }, 1200 | "semver": { 1201 | "version": "6.3.0", 1202 | "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", 1203 | "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", 1204 | "dev": true 1205 | }, 1206 | "shebang-command": { 1207 | "version": "1.2.0", 1208 | "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", 1209 | "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", 1210 | "dev": true, 1211 | "requires": { 1212 | "shebang-regex": "^1.0.0" 1213 | } 1214 | }, 1215 | "shebang-regex": { 1216 | "version": "1.0.0", 1217 | "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", 1218 | "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", 1219 | "dev": true 1220 | }, 1221 | "signal-exit": { 1222 | "version": "3.0.2", 1223 | "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", 1224 | "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", 1225 | "dev": true 1226 | }, 1227 | "slice-ansi": { 1228 | "version": "2.1.0", 1229 | "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", 1230 | "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", 1231 | "dev": true, 1232 | "requires": { 1233 | "ansi-styles": "^3.2.0", 1234 | "astral-regex": "^1.0.0", 1235 | "is-fullwidth-code-point": "^2.0.0" 1236 | }, 1237 | "dependencies": { 1238 | "is-fullwidth-code-point": { 1239 | "version": "2.0.0", 1240 | "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", 1241 | "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", 1242 | "dev": true 1243 | } 1244 | } 1245 | }, 1246 | "source-map": { 1247 | "version": "0.5.7", 1248 | "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", 1249 | "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", 1250 | "dev": true 1251 | }, 1252 | "sprintf-js": { 1253 | "version": "1.0.3", 1254 | "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", 1255 | "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", 1256 | "dev": true 1257 | }, 1258 | "string-width": { 1259 | "version": "4.2.0", 1260 | "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", 1261 | "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", 1262 | "dev": true, 1263 | "requires": { 1264 | "emoji-regex": "^8.0.0", 1265 | "is-fullwidth-code-point": "^3.0.0", 1266 | "strip-ansi": "^6.0.0" 1267 | }, 1268 | "dependencies": { 1269 | "strip-ansi": { 1270 | "version": "6.0.0", 1271 | "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", 1272 | "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", 1273 | "dev": true, 1274 | "requires": { 1275 | "ansi-regex": "^5.0.0" 1276 | } 1277 | } 1278 | } 1279 | }, 1280 | "string.prototype.trimleft": { 1281 | "version": "2.1.1", 1282 | "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz", 1283 | "integrity": "sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag==", 1284 | "dev": true, 1285 | "requires": { 1286 | "define-properties": "^1.1.3", 1287 | "function-bind": "^1.1.1" 1288 | } 1289 | }, 1290 | "string.prototype.trimright": { 1291 | "version": "2.1.1", 1292 | "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz", 1293 | "integrity": "sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g==", 1294 | "dev": true, 1295 | "requires": { 1296 | "define-properties": "^1.1.3", 1297 | "function-bind": "^1.1.1" 1298 | } 1299 | }, 1300 | "strip-ansi": { 1301 | "version": "5.2.0", 1302 | "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", 1303 | "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", 1304 | "dev": true, 1305 | "requires": { 1306 | "ansi-regex": "^4.1.0" 1307 | }, 1308 | "dependencies": { 1309 | "ansi-regex": { 1310 | "version": "4.1.0", 1311 | "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", 1312 | "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", 1313 | "dev": true 1314 | } 1315 | } 1316 | }, 1317 | "strip-json-comments": { 1318 | "version": "3.0.1", 1319 | "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.0.1.tgz", 1320 | "integrity": "sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==", 1321 | "dev": true 1322 | }, 1323 | "supports-color": { 1324 | "version": "5.5.0", 1325 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", 1326 | "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", 1327 | "dev": true, 1328 | "requires": { 1329 | "has-flag": "^3.0.0" 1330 | } 1331 | }, 1332 | "table": { 1333 | "version": "5.4.6", 1334 | "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", 1335 | "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", 1336 | "dev": true, 1337 | "requires": { 1338 | "ajv": "^6.10.2", 1339 | "lodash": "^4.17.14", 1340 | "slice-ansi": "^2.1.0", 1341 | "string-width": "^3.0.0" 1342 | }, 1343 | "dependencies": { 1344 | "emoji-regex": { 1345 | "version": "7.0.3", 1346 | "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", 1347 | "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", 1348 | "dev": true 1349 | }, 1350 | "is-fullwidth-code-point": { 1351 | "version": "2.0.0", 1352 | "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", 1353 | "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", 1354 | "dev": true 1355 | }, 1356 | "string-width": { 1357 | "version": "3.1.0", 1358 | "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", 1359 | "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", 1360 | "dev": true, 1361 | "requires": { 1362 | "emoji-regex": "^7.0.1", 1363 | "is-fullwidth-code-point": "^2.0.0", 1364 | "strip-ansi": "^5.1.0" 1365 | } 1366 | } 1367 | } 1368 | }, 1369 | "text-table": { 1370 | "version": "0.2.0", 1371 | "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", 1372 | "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", 1373 | "dev": true 1374 | }, 1375 | "through": { 1376 | "version": "2.3.8", 1377 | "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", 1378 | "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", 1379 | "dev": true 1380 | }, 1381 | "tmp": { 1382 | "version": "0.0.33", 1383 | "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", 1384 | "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", 1385 | "dev": true, 1386 | "requires": { 1387 | "os-tmpdir": "~1.0.2" 1388 | } 1389 | }, 1390 | "to-fast-properties": { 1391 | "version": "2.0.0", 1392 | "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", 1393 | "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", 1394 | "dev": true 1395 | }, 1396 | "tslib": { 1397 | "version": "1.10.0", 1398 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", 1399 | "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", 1400 | "dev": true 1401 | }, 1402 | "type-check": { 1403 | "version": "0.3.2", 1404 | "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", 1405 | "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", 1406 | "dev": true, 1407 | "requires": { 1408 | "prelude-ls": "~1.1.2" 1409 | } 1410 | }, 1411 | "type-fest": { 1412 | "version": "0.8.1", 1413 | "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", 1414 | "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", 1415 | "dev": true 1416 | }, 1417 | "uri-js": { 1418 | "version": "4.2.2", 1419 | "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", 1420 | "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", 1421 | "dev": true, 1422 | "requires": { 1423 | "punycode": "^2.1.0" 1424 | } 1425 | }, 1426 | "v8-compile-cache": { 1427 | "version": "2.1.0", 1428 | "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz", 1429 | "integrity": "sha512-usZBT3PW+LOjM25wbqIlZwPeJV+3OSz3M1k1Ws8snlW39dZyYL9lOGC5FgPVHfk0jKmjiDV8Z0mIbVQPiwFs7g==", 1430 | "dev": true 1431 | }, 1432 | "which": { 1433 | "version": "1.3.1", 1434 | "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", 1435 | "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", 1436 | "dev": true, 1437 | "requires": { 1438 | "isexe": "^2.0.0" 1439 | } 1440 | }, 1441 | "word-wrap": { 1442 | "version": "1.2.3", 1443 | "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", 1444 | "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", 1445 | "dev": true 1446 | }, 1447 | "wrappy": { 1448 | "version": "1.0.2", 1449 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 1450 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", 1451 | "dev": true 1452 | }, 1453 | "write": { 1454 | "version": "1.0.3", 1455 | "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", 1456 | "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", 1457 | "dev": true, 1458 | "requires": { 1459 | "mkdirp": "^0.5.1" 1460 | } 1461 | } 1462 | } 1463 | } 1464 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web-clipper", 3 | "main": "./lib/web-clipper", 4 | "version": "1.1.1", 5 | "description": "Clip web pages into new notes", 6 | "keywords": [ 7 | "inkdrop", 8 | "web", 9 | "clipper", 10 | "notes", 11 | "readability" 12 | ], 13 | "repository": "https://github.com/libeanim/inkdrop-web-clipper", 14 | "license": "MIT", 15 | "engines": { 16 | "inkdrop": "^4.x" 17 | }, 18 | "dependencies": { 19 | "core-js": "^2.6.11" 20 | }, 21 | "devDependencies": { 22 | "babel-eslint": "^10.0.3", 23 | "eslint": "^6.1.0", 24 | "eslint-config-prettier": "^6.0.0", 25 | "eslint-plugin-prettier": "^3.1.0", 26 | "eslint-plugin-react": "^7.14.3", 27 | "prettier": "^1.18.2" 28 | } 29 | } 30 | --------------------------------------------------------------------------------