KGrabber

extracts links from kissanime.ru and similar sites

  1. // ==UserScript==
  2. // @name KGrabber
  3. // @namespace thorou
  4. // @version 3.3.2-b107
  5. // @description extracts links from kissanime.ru and similar sites
  6. // @author Thorou
  7. // @license GPLv3 - http://www.gnu.org/licenses/gpl-3.0.txt
  8. // @homepageURL https://github.com/thorio/KGrabber/
  9. // @match http*://kissanime.ru/*
  10. // @match http*://kimcartoon.to/*
  11. // @match http*://kissasian.sh/*
  12. // @match http*://kisstvshow.to/*
  13. // @connect rapidvideo.com
  14. // @connect googleusercontent.com
  15. // @connect googlevideo.com
  16. // @connect fembed.com
  17. // @grant GM_xmlhttpRequest
  18. // @grant GM_getValue
  19. // @grant GM_setValue
  20. // @run-at document-end
  21. // @noframes
  22. // @require https://code.jquery.com/jquery-3.3.1.min.js
  23. // ==/UserScript==
  24.  
  25. // bundled with browserify
  26. (function() {
  27.  
  28. function outer(modules, cache, entry) {
  29. var previousRequire = typeof require == "function" && require;
  30.  
  31. function newRequire(name, jumped){
  32. if(!cache[name]) {
  33. if(!modules[name]) {
  34. var currentRequire = typeof require == "function" && require;
  35. if (!jumped && currentRequire) return currentRequire(name, true);
  36. if (previousRequire) return previousRequire(name, true);
  37. var err = new Error('Cannot find module \'' + name + '\'');
  38. err.code = 'MODULE_NOT_FOUND';
  39. throw err;
  40. }
  41. var m = cache[name] = {exports:{}};
  42. modules[name][0].call(m.exports, function(x){
  43. var id = modules[name][1][x];
  44. return newRequire(id ? id : x);
  45. },m,m.exports,outer,modules,cache,entry);
  46. }
  47. return cache[name].exports;
  48. }
  49. for(var i=0;i<entry.length;i++) newRequire(entry[i]);
  50. return newRequire;
  51. }
  52.  
  53. return outer;
  54.  
  55. })()({1:[function(require,module,exports){
  56. "use strict";
  57. // src\js\actions\beta.js
  58.  
  59. const util = require("../util"),
  60. shared = require("./shared"),
  61. { Action, LinkTypes } = require("kgrabber-types");
  62.  
  63. module.exports = [
  64. getAction(["beta", "beta5"], LinkTypes.DIRECT),
  65. getAction(["beta360p"], LinkTypes.HLS),
  66. ];
  67.  
  68. function getAction(servers, resultType) {
  69. return new Action("decrypt", {
  70. executeFunc: async (status, setProgress) => {
  71. await shared.eachEpisode(status.episodes, decrypt, setProgress);
  72. status.linkType = resultType;
  73. },
  74. availableFunc: (action, status) => {
  75. return shared.availableFunc(status, {
  76. linkType: LinkTypes.OVELWRAP,
  77. servers: servers,
  78. });
  79. },
  80. automatic: true,
  81. });
  82. }
  83.  
  84. async function decrypt(episode) {
  85. if (episode.error) {
  86. return;
  87. }
  88. episode.processedLink = await util.kissCrypto.decrypt(episode.functionalLink);
  89. }
  90.  
  91. },{"../util":55,"./shared":5,"kgrabber-types":37}],2:[function(require,module,exports){
  92. "use strict";
  93. // src\js\actions\generic.js
  94.  
  95. const shared = require("./shared"),
  96. config = require("../config"),
  97. { Action } = require("kgrabber-types");
  98.  
  99. module.exports = [
  100. new Action("reset", {
  101. executeFunc: async (status, setProgress) => {
  102. await shared.eachEpisode(status.episodes, reset, setProgress);
  103. status.linkType = config.sites.current().servers.get(status.serverID).linkType;
  104. status.hasReset = true;
  105. },
  106. availableFunc: (action, status) => {
  107. for (let episode of status.episodes) {
  108. if ((episode.error && episode.grabbedLink) || episode.processedLink) {
  109. return true;
  110. }
  111. }
  112. return false;
  113. },
  114. }),
  115. ];
  116.  
  117. async function reset(episode) {
  118. episode.error = "";
  119. episode.processedLink = "";
  120. }
  121.  
  122. },{"../config":6,"./shared":5,"kgrabber-types":37}],3:[function(require,module,exports){
  123. "use strict";
  124. // src\js\actions\index.js
  125.  
  126. const statusManager = require("../statusManager");
  127.  
  128. const status = statusManager.get();
  129.  
  130. let actions = [].concat(
  131. require("./generic"),
  132. require("./beta"),
  133. require("./nova")
  134. );
  135.  
  136. exports.all = () =>
  137. actions;
  138.  
  139. exports.available = () =>
  140. actions.filter((action) =>
  141. action.isAvailable(status)
  142. );
  143.  
  144. exports.add = (...action) => {
  145. actions.push(...action);
  146. };
  147.  
  148. exports.execute = async (action, setSpinnerText) => {
  149. await action.invoke(status, setSpinnerText);
  150. if (action.automatic) {
  151. status.automaticDone = true;
  152. }
  153. };
  154.  
  155. },{"../statusManager":41,"./beta":1,"./generic":2,"./nova":4}],4:[function(require,module,exports){
  156. "use strict";
  157. // src\js\actions\nova.js
  158.  
  159. const ajax = require("../util/ajax"),
  160. util = require("../util"),
  161. preferenceManager = require("../config/preferenceManager"),
  162. shared = require("./shared"),
  163. { Action, LinkTypes } = require("kgrabber-types");
  164.  
  165. const preferences = preferenceManager.get();
  166.  
  167. module.exports = [
  168. new Action("get direct links", {
  169. executeFunc: async (status, setProgress) => {
  170. await shared.eachEpisode(status.episodes, getDirect, setProgress);
  171. status.linkType = LinkTypes.DIRECT;
  172. },
  173. availableFunc: (action, status) => {
  174. return shared.availableFunc(status, {
  175. linkType: LinkTypes.EMBED,
  176. servers: ["nova", "fe"],
  177. });
  178. },
  179. }),
  180. ];
  181.  
  182. async function getDirect(episode) {
  183. if (episode.error) return;
  184.  
  185. let sources = await getSources(episode);
  186. if (!sources) return;
  187.  
  188. let url = findQuality(episode, sources);
  189. if (!url) return;
  190.  
  191. episode.processedLink = url;
  192. }
  193.  
  194.  
  195.  
  196. async function getSources(episode) {
  197. let response = await ajax.post(`https://www.fembed.com/api/source/${episode.functionalLink.match(/\/([^/]*?)$/)[1]}`);
  198. let json;
  199.  
  200. try {
  201. json = JSON.parse(response.response);
  202. } catch (error) {
  203. episode.error = "parsing error";
  204. util.log.err(episode.error, episode, response);
  205. return null;
  206. }
  207.  
  208. if (!json.success) {
  209. episode.error = json.data;
  210. util.log.err(episode.error, episode, response);
  211. return null;
  212. }
  213.  
  214. return json.data;
  215. }
  216.  
  217. function findQuality(episode, sources) {
  218. let parsedQualityPrefs = preferences.general.quality_order.replace(/\s/g, "").split(",");
  219.  
  220. for (let quality of parsedQualityPrefs) {
  221. let source = sources.find((s) => s.label == quality + "p");
  222. if (source) return source.file;
  223. }
  224.  
  225. let availableQualities = sources.map((s) => s.label).join(", ");
  226. episode.error = "preferred qualities not found. available: " + availableQualities;
  227. util.log.err(episode.error, episode, sources);
  228. }
  229.  
  230. },{"../config/preferenceManager":7,"../util":55,"../util/ajax":54,"./shared":5,"kgrabber-types":37}],5:[function(require,module,exports){
  231. "use strict";
  232. // src\js\actions\shared.js
  233.  
  234. const util = require("../util");
  235.  
  236. exports.eachEpisode = (episodes, func, setProgress) => {
  237. let promises = [];
  238. let progress = 0;
  239. for (let episode of episodes) {
  240. promises.push(
  241. func(episode).catch((e) => {
  242. episode.error = "something went wrong; see console for details";
  243. util.log.err(e);
  244. }).finally(() => {
  245. progress++;
  246. setProgress(`${progress}/${promises.length}`);
  247. })
  248. );
  249. }
  250. setProgress(`0/${promises.length}`);
  251. return Promise.all(promises);
  252. };
  253.  
  254. exports.availableFunc = (status, { linkType, servers }) => {
  255. if (!servers.includes(status.serverID)) {
  256. return false;
  257. }
  258. if (linkType != status.linkType) {
  259. return false;
  260. }
  261. return true;
  262. };
  263.  
  264. },{"../util":55}],6:[function(require,module,exports){
  265. "use strict";
  266. // src\js\config\index.js
  267. module.exports = {
  268. preferenceManager: require("./preferenceManager"),
  269. sites: require("./sites"),
  270. };
  271.  
  272. },{"./preferenceManager":7,"./sites":8}],7:[function(require,module,exports){
  273. "use strict";
  274. // src\js\config\preferenceManager.js
  275. const util = require("../util");
  276.  
  277. const defaultPreferences = {
  278. general: {
  279. quality_order: "1080, 720, 480, 360",
  280. },
  281. internet_download_manager: {
  282. idm_path: "C:\\Program Files (x86)\\Internet Download Manager\\IDMan.exe",
  283. download_path: "%~dp0",
  284. arguments: "/a",
  285. keep_title_in_episode_name: false,
  286. },
  287. compatibility: {
  288. force_default_grabber: false,
  289. enable_experimental_grabbers: false,
  290. disable_automatic_actions: false,
  291. },
  292. };
  293.  
  294. let preferences;
  295.  
  296. exports.get = () => {
  297. if (preferences === undefined) {
  298. preferences = load(defaultPreferences);
  299. }
  300. return preferences;
  301. };
  302.  
  303. let save = exports.save = (newPreferences) => {
  304. util.clear(preferences);
  305. util.merge(preferences, newPreferences);
  306. GM_setValue("KG-preferences", JSON.stringify(preferences));
  307. };
  308.  
  309. exports.reset = () =>
  310. save({});
  311.  
  312. function load(defaults) {
  313. let saved = JSON.parse(GM_getValue("KG-preferences", "{}"));
  314.  
  315. for (let i in saved) {
  316. if (defaults[i] === undefined) {
  317. delete saved[i];
  318. } else {
  319. for (let j in saved[i]) {
  320. if (defaults[i][j] === undefined) {
  321. delete saved[i][j];
  322. }
  323. }
  324. }
  325. }
  326. return util.merge(util.clone(defaults), saved);
  327. }
  328.  
  329. function getPreferredServers() {
  330. return JSON.parse(GM_getValue("preferredServers", "{}"));
  331. }
  332.  
  333. function savePreferredServers(servers) {
  334. GM_setValue("preferredServers", JSON.stringify(servers));
  335. }
  336.  
  337. exports.getPreferredServer = (host) =>
  338. getPreferredServers()[host];
  339.  
  340. exports.setPreferredServer = (host, server) => {
  341. let saved = getPreferredServers();
  342. saved[host] = server;
  343. savePreferredServers(saved);
  344. };
  345.  
  346. },{"../util":55}],8:[function(require,module,exports){
  347. "use strict";
  348. // src\js\config\sites\index.js
  349.  
  350. const { Dictionary } = require("kgrabber-types"),
  351. page = require("../../ui/page");
  352.  
  353. const sites = new Dictionary([
  354. require("./kissanime_ru"),
  355. require("./kimcartoon"),
  356. require("./kissasian"),
  357. require("./kisstvshow"),
  358. ]);
  359.  
  360. exports.current = () =>
  361. sites.get(page.location.hostname);
  362.  
  363. exports.add = (...newSites) => {
  364. sites.add(...newSites);
  365. };
  366.  
  367. },{"../../ui/page":48,"./kimcartoon":9,"./kissanime_ru":10,"./kissasian":11,"./kisstvshow":12,"kgrabber-types":37}],9:[function(require,module,exports){
  368. "use strict";
  369. // src\js\config\sites\kimcartoon.js
  370. const { Server, Site, Dictionary, LinkTypes } = require("kgrabber-types"),
  371. uiFix = require("./patches/kimcartoon_UIFix");
  372.  
  373. let servers = new Dictionary([
  374. new Server("hx", {
  375. regex: /src="(\/\/playhydrax.com\/\?v=.*?)"/,
  376. captureGroup: 1,
  377. trimQuotes: false,
  378. name: "HX (hydrax)",
  379. linkType: LinkTypes.EMBED,
  380. }),
  381.  
  382. new Server("fe", {
  383. regex: /"(https:\/\/www.luxubu.review\/v\/.*?)"/,
  384. captureGroup: 1,
  385. trimQuotes: false,
  386. name: "FE (luxubu.review)",
  387. linkType: LinkTypes.EMBED,
  388. }),
  389.  
  390. new Server("beta", {
  391. regex: /"(https:\/\/redirector.googlevideo.com\/videoplayback\?.*?)"/,
  392. captureGroup: 1,
  393. trimQuotes: false,
  394. name: "Beta",
  395. linkType: LinkTypes.DIRECT,
  396. }),
  397.  
  398. new Server("alpha", {
  399. regex: /"(https:\/\/redirector.googlevideo.com\/videoplayback\?.*?)"/,
  400. captureGroup: 1,
  401. trimQuotes: false,
  402. name: "Alpha (googleusercontent.com)",
  403. linkType: LinkTypes.DIRECT,
  404. }),
  405. ]);
  406.  
  407. module.exports = new Site("kimcartoon.to", {
  408. contentPath: "Cartoon",
  409. noCaptchaServer: "rapid",
  410. buttonColor: "#ecc835",
  411. buttonTextColor: "#000",
  412. servers,
  413. patches: uiFix,
  414. });
  415.  
  416. },{"./patches/kimcartoon_UIFix":13,"kgrabber-types":37}],10:[function(require,module,exports){
  417. "use strict";
  418. // src\js\config\sites\kissanime_ru.js
  419. const { Server, Site, Dictionary, LinkTypes } = require("kgrabber-types");
  420.  
  421. let servers = new Dictionary([
  422. new Server("hydrax", {
  423. regex: /"(https:\/\/playhydrax.com\/\?v=.*?)"/,
  424. captureGroup: 1,
  425. trimQuotes: false,
  426. name: "HydraX (no captcha)",
  427. linkType: LinkTypes.EMBED,
  428. customStep: "modalBegin",
  429. }),
  430.  
  431. new Server("nova", {
  432. regex: /"(https:\/\/(?:www).(?:feurl.com|novelplanet.me)\/v\/.*?)"/,
  433. captureGroup: 1,
  434. trimQuotes: false,
  435. name: "Nova",
  436. linkType: LinkTypes.EMBED,
  437. customStep: "modalBegin",
  438. }),
  439.  
  440. new Server("beta", {
  441. regex: /<select id="slcQualix"><option value="([^"]+)" ?(selected)?>/,
  442. captureGroup: 1,
  443. trimQuotes: false,
  444. name: "Beta",
  445. linkType: LinkTypes.OVELWRAP,
  446. customStep: "modalBegin",
  447. }),
  448.  
  449. new Server("beta360p", {
  450. regex: /<select id="slcQualix"><option value="([^"]+)" ?(selected)?>/,
  451. captureGroup: 1,
  452. trimQuotes: false,
  453. name: "Beta360P",
  454. linkType: LinkTypes.OVELWRAP,
  455. customStep: "modalBegin",
  456. }),
  457.  
  458. new Server("beta5", {
  459. regex: /<select id="slcQualix"><option value="([^"]+)" ?(selected)?>/,
  460. captureGroup: 1,
  461. trimQuotes: false,
  462. name: "Beta5",
  463. linkType: LinkTypes.OVELWRAP,
  464. customStep: "modalBegin",
  465. }),
  466.  
  467. new Server("mp4upload", {
  468. regex: /"(https:\/\/www.mp4upload.com\/embed-.*?)"/,
  469. captureGroup: 1,
  470. trimQuotes: false,
  471. name: "Mp4Upload",
  472. linkType: LinkTypes.EMBED,
  473. customStep: "modalBegin",
  474. }),
  475. ]);
  476.  
  477. module.exports = new Site("kissanime.ru", {
  478. contentPath: "Anime",
  479. noCaptchaServer: "hydrax",
  480. buttonColor: "#548602",
  481. buttonTextColor: "#fff",
  482. servers,
  483. });
  484.  
  485. },{"kgrabber-types":37}],11:[function(require,module,exports){
  486. "use strict";
  487. // src\js\config\sites\kissasian.js
  488. const { Server, Site, Dictionary, LinkTypes } = require("kgrabber-types"),
  489. uiFix = require("./patches/kissasian_UIFix");
  490.  
  491. let servers = new Dictionary([
  492. new Server("openload", {
  493. regex: /"https:\/\/openload.co\/embed\/.*?"/,
  494. name: "Openload",
  495. linkType: LinkTypes.EMBED,
  496. }),
  497.  
  498. new Server("beta", {
  499. regex: /"https:\/\/redirector.googlevideo.com\/videoplayback\?.*?"/,
  500. name: "Beta",
  501. linkType: LinkTypes.DIRECT,
  502. }),
  503.  
  504. new Server("fe", {
  505. regex: /"https:\/\/www.gaobook.review\/v\/.*?"/,
  506. name: "FE (gaobook.review)",
  507. linkType: LinkTypes.EMBED,
  508. }),
  509.  
  510. new Server("mp", {
  511. regex: /"https:\/\/www.mp4upload.com\/embed-.*?"/,
  512. name: "MP (mp4upload.com)",
  513. linkType: LinkTypes.EMBED,
  514. }),
  515.  
  516. new Server("fb", {
  517. regex: /"https:\/\/video.xx.fbcdn.net\/v\/.*?"/,
  518. name: "FB (fbcdn.net)",
  519. linkType: LinkTypes.DIRECT,
  520. }),
  521.  
  522. new Server("alpha", {
  523. regex: /"https:\/\/redirector.googlevideo.com\/videoplayback\?.*?"/,
  524. name: "Alpha",
  525. linkType: LinkTypes.DIRECT,
  526. }),
  527. ]);
  528.  
  529. module.exports = new Site("kissasian.sh", {
  530. contentPath: "Drama",
  531. noCaptchaServer: "rapid",
  532. buttonColor: "#F5B54B",
  533. buttonTextColor: "#000",
  534. servers,
  535. patches: uiFix,
  536. });
  537.  
  538. },{"./patches/kissasian_UIFix":14,"kgrabber-types":37}],12:[function(require,module,exports){
  539. "use strict";
  540. // src\js\config\sites\kisstvshow.js
  541. const { Server, Site, Dictionary, LinkTypes } = require("kgrabber-types");
  542.  
  543. let servers = new Dictionary([
  544. new Server("openload", {
  545. regex: /"https:\/\/openload.co\/embed\/.*?"/,
  546. name: "Openload",
  547. linkType: LinkTypes.EMBED,
  548. }),
  549.  
  550. new Server("streamango", {
  551. regex: /"https:\/\/streamango.com\/embed\/.*?"/,
  552. name: "Streamango",
  553. linkType: LinkTypes.EMBED,
  554. }),
  555.  
  556. new Server("beta", {
  557. regex: /"https:\/\/redirector.googlevideo.com\/videoplayback\?.*?"/,
  558. name: "Beta",
  559. linkType: LinkTypes.DIRECT,
  560. }),
  561.  
  562. new Server("fb", {
  563. regex: /"https:\/\/video.xx.fbcdn.net\/v\/.*?"/,
  564. name: "FB (fbcdn.net)",
  565. linkType: LinkTypes.DIRECT,
  566. }),
  567.  
  568. new Server("gp", {
  569. regex: /"https:\/\/redirector.googlevideo.com\/videoplayback\?.*?"/,
  570. name: "GP (googleusercontent.com)",
  571. linkType: LinkTypes.DIRECT,
  572. }),
  573.  
  574. new Server("fe", {
  575. regex: /"https:\/\/www.rubicstreaming.com\/v\/.*?"/,
  576. name: "FE (rubicstreaming.com)",
  577. linkType: LinkTypes.EMBED,
  578. }),
  579. ]);
  580.  
  581. module.exports = new Site("kisstvshow.to", {
  582. contentPath: "Show",
  583. noCaptchaServer: "rapid",
  584. buttonColor: "#F5B54B",
  585. buttonTextColor: "#000",
  586. servers,
  587. });
  588.  
  589. },{"kgrabber-types":37}],13:[function(require,module,exports){
  590. "use strict";
  591. // src\js\config\sites\patches\kimcartoon_UIFix.js
  592. exports.linkDisplay = () => {
  593. let $ld = $("#KG-linkdisplay");
  594. $("#KG-linkdisplay-title").css({
  595. "font-size": "20px",
  596. "color": $("a.bigChar").css("color"),
  597. });
  598. fixTitle($ld);
  599. };
  600.  
  601. exports.preferences = () => {
  602. let $pf = $("#KG-preferences");
  603. fixTitle($pf);
  604. };
  605.  
  606. exports.widget = () => {
  607. let $opts = $("#KG-opts-widget");
  608. $opts.insertAfter(`#rightside .clear2:eq(2)`);
  609. let title = $opts.find(".barTitle").html();
  610. $opts.before(`<div class="title-list icon">${title}</div><div class="clear2"></div>`);
  611. $(".icon:eq(1)").css({ "width": "100%", "box-sizing": "border-box" });
  612. $(".KG-preferences-button").css("margin-top", "5px");
  613. $opts.find(".barTitle").remove();
  614. fixTitle($opts);
  615. };
  616.  
  617. function fixTitle(element) {
  618. $(".KG-dialog-title").css("font-size", "18px");
  619. element.find(".arrow-general").remove();
  620. element.find(".barTitle").removeClass("barTitle")
  621. .css({
  622. "height": "20px",
  623. "padding": "5px",
  624. });
  625. }
  626.  
  627. },{}],14:[function(require,module,exports){
  628. "use strict";
  629. // src\js\config\sites\patches\kissasian_UIFix.js
  630. exports.widget = () => {
  631. $(".KG-preferences-button").css("filter", "invert(0.7)");
  632. };
  633.  
  634. },{}],15:[function(require,module,exports){
  635. "use strict";
  636. // generated file, provides contents of src\css
  637. module.exports = `
  638. /* src\css\captchaModal.less */
  639. .KG-captchaModal-container {
  640. background-color: #0005;
  641. position: fixed;
  642. top: 0px;
  643. left: 0px;
  644. width: 100vw;
  645. height: 100vh;
  646. z-index: 9000;
  647. overflow: hidden scroll;
  648. }
  649. .KG-captchaModal {
  650. width: 1000px;
  651. margin: auto;
  652. margin-top: 195px;
  653. margin-bottom: 50px;
  654. }
  655. .KG-captchaModal-description-header {
  656. width: 100%;
  657. font-size: 1.7em;
  658. text-align: center;
  659. }
  660. .KG-captchaModal-description-header span {
  661. color: #d5f406;
  662. margin-right: 20px;
  663. }
  664. .KG-captchaModal-description-header span:not(:last-child)::after {
  665. content: "-";
  666. margin-left: 20px;
  667. color: #fff;
  668. }
  669. .KG-captchaModal-image-container {
  670. display: flex;
  671. flex-direction: row;
  672. flex-wrap: wrap;
  673. justify-content: center;
  674. }
  675. .KG-captchaModal-image-container img {
  676. margin: 30px;
  677. width: 160px;
  678. cursor: pointer;
  679. }
  680. .KG-captchaModal-image-container img.active {
  681. outline: 5px solid #d5f406;
  682. }
  683. #KG-captchaModal-status {
  684. margin-left: 25px;
  685. }
  686.  
  687. /* src\css\colors.less */
  688.  
  689. /* src\css\general.less */
  690. .KG-button {
  691. background-color: #548602;
  692. color: #fff;
  693. border: none;
  694. padding: 5px 12px;
  695. font-size: 15px;
  696. margin: 3px;
  697. float: left;
  698. cursor: pointer;
  699. }
  700. .KG-button-container {
  701. margin-top: 10px;
  702. height: 34px;
  703. }
  704. .KG-dialog-title {
  705. width: 80%;
  706. float: left;
  707. }
  708. .KG-dialog-close {
  709. float: right;
  710. cursor: pointer;
  711. font-size: 16px;
  712. margin-right: -4px;
  713. margin-top: 1px;
  714. }
  715. .right {
  716. float: right;
  717. }
  718. .left {
  719. float: left;
  720. }
  721.  
  722. /* src\css\linkDisplay.less */
  723. #KG-linkdisplay-text {
  724. word-break: break-all;
  725. }
  726. .KG-linkdisplay-row {
  727. display: flex;
  728. flex-direction: row;
  729. }
  730. .KG-linkdisplay-row a {
  731. text-overflow: ellipsis;
  732. overflow: hidden;
  733. white-space: nowrap;
  734. }
  735. .KG-linkdisplay-episodenumber {
  736. min-width: 30px;
  737. text-align: right;
  738. user-select: none;
  739. margin-right: 5px;
  740. }
  741. #KG-linkdisplay-export {
  742. margin-top: 10px;
  743. }
  744. #KG-linkdisplay-export-text {
  745. width: 100%;
  746. height: 150px;
  747. min-height: 40px;
  748. resize: vertical;
  749. background-color: #222;
  750. color: #fff;
  751. border: none;
  752. }
  753. #KG-linkdisplay-export-dropdown {
  754. margin: 6px;
  755. float: left;
  756. color: #fff;
  757. background-color: #222;
  758. cursor: pointer;
  759. }
  760.  
  761. /* src\css\loader.less */
  762. #KG-loader-text {
  763. width: 100%;
  764. text-align: center;
  765. margin-top: -40px;
  766. margin-bottom: 40px;
  767. min-height: 20px;
  768. }
  769. /*
  770. https://projects.lukehaas.me/css-loaders/
  771. */
  772. .loader,
  773. .loader:after {
  774. border-radius: 50%;
  775. width: 10em;
  776. height: 10em;
  777. }
  778. .loader {
  779. margin: 0px auto;
  780. font-size: 5px;
  781. position: relative;
  782. text-indent: -9999em;
  783. border-top: 1.1em solid rgba(255, 255, 255, 0.2);
  784. border-right: 1.1em solid rgba(255, 255, 255, 0.2);
  785. border-bottom: 1.1em solid rgba(255, 255, 255, 0.2);
  786. border-left: 1.1em solid #ffffff;
  787. -webkit-transform: translateZ(0);
  788. -ms-transform: translateZ(0);
  789. transform: translateZ(0);
  790. -webkit-animation: load8 1.1s infinite linear;
  791. animation: load8 1.1s infinite linear;
  792. }
  793. @-webkit-keyframes load8 {
  794. 0% {
  795. -webkit-transform: rotate(0deg);
  796. transform: rotate(0deg);
  797. }
  798. 100% {
  799. -webkit-transform: rotate(360deg);
  800. transform: rotate(360deg);
  801. }
  802. }
  803. @keyframes load8 {
  804. 0% {
  805. -webkit-transform: rotate(0deg);
  806. transform: rotate(0deg);
  807. }
  808. 100% {
  809. -webkit-transform: rotate(360deg);
  810. transform: rotate(360deg);
  811. }
  812. }
  813.  
  814. /* src\css\pageWidgets.less */
  815. .KG-episodelist-header {
  816. width: 3%;
  817. text-align: center !important;
  818. }
  819. .KG-episodelist-number {
  820. text-align: right;
  821. padding-right: 4px;
  822. }
  823. .KG-episodelist-button {
  824. background-color: #548602;
  825. color: #fff;
  826. border: none;
  827. cursor: pointer;
  828. }
  829.  
  830. /* src\css\preferences.less */
  831. #KG-preferences-container-outer {
  832. overflow: auto;
  833. }
  834. .KG-preferences-header {
  835. font-size: 17px;
  836. letter-spacing: 0px;
  837. width: 100%;
  838. margin: 10px 0 5px 0;
  839. }
  840. #KG-preferences-container {
  841. overflow: auto;
  842. }
  843. #KG-preferences-container div {
  844. box-sizing: border-box;
  845. height: 26px;
  846. width: 50%;
  847. padding: 0 5px;
  848. margin: 2px 0;
  849. float: left;
  850. line-height: 26px;
  851. font-size: 14px;
  852. }
  853. #KG-preferences-container div span {
  854. padding-top: 5px;
  855. }
  856. .KG-preferences-button {
  857. width: 18px;
  858. height: 18px;
  859. margin: 3px;
  860. float: right;
  861. border: none;
  862. background: transparent;
  863. opacity: 0.7;
  864. background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsSAAALEgHS3X78AAABBklEQVRIidVWOw6DMAx9dGBttq49GkfgKByBo9AbwA26doOxLK4iOTSkTuLSn/okS2CeX8wjHwoighIhsdCU7bTqWyEN0HI8C7nOWuRFS3fYa0NENRH19IienxmhbtGMiTtchZyGswyS+walwqY0J2HRVqwsCqepAXBRdi5hBnAAMLpnoUVVQnwCcOKYIpySNaIWSbOFOG88nslwVxbllrLt9ui/NsPaeQawTxVrVnIviINzfa5YM4AkrsZXLCq8GASOFehY0BfvIuLDSjOYRXVicY1E1HGMCV7904XWvCAOrm1WmTfvQw7q3XRWdJ3mfPrAkQ59d+xVYS/BfXjoi3V//lcB4AYxBp8XouibewAAAABJRU5ErkJggg==");
  865. background-size: cover;
  866. cursor: pointer;
  867. }
  868. .KG-preferences-button:hover {
  869. opacity: 1;
  870. }
  871. .KG-preferences-input-text {
  872. width: 150px;
  873. border: 1px solid #666;
  874. background: #222;
  875. padding: 3px;
  876. margin-left: 5px;
  877. color: #fff;
  878. }
  879. .KG-preferences-input-checkbox {
  880. height: 22px;
  881. }
  882.  
  883. /* src\css\widget.less */
  884. .KG-widget-episode {
  885. width: 40px;
  886. border: 1px solid #666;
  887. color: #fff;
  888. background-color: #222;
  889. padding: 3px;
  890. }
  891. #KG-widget-server {
  892. width: 100%;
  893. font-size: 14.5px;
  894. color: #fff;
  895. background-color: #222;
  896. cursor: pointer;
  897. }
  898. `;
  899. },{}],16:[function(require,module,exports){
  900. "use strict";
  901. // src\js\exporters\aria2c.js
  902.  
  903. const { LinkTypes, Exporter } = require("kgrabber-types");
  904.  
  905. module.exports = new Exporter({
  906. name: "aria2c file",
  907. extension: "txt",
  908. requireSamePage: false,
  909. linkTypes: [LinkTypes.DIRECT],
  910. }, runExport);
  911.  
  912. function runExport(status) {
  913. let listing = $(".listing a").get().reverse();
  914. let str = "";
  915. for (let episode of status.episodes) {
  916. if (!episode.error) {
  917. str += `${episode.functionalLink}\n out=${listing[episode.episodeNumber-1].innerText}.mp4\n`;
  918. }
  919. }
  920. return str;
  921. }
  922.  
  923. },{"kgrabber-types":37}],17:[function(require,module,exports){
  924. "use strict";
  925. // src\js\exporters\csv.js
  926.  
  927. const { LinkTypes, Exporter } = require("kgrabber-types"),
  928. page = require("../ui/page");
  929.  
  930. module.exports = new Exporter({
  931. name: "csv",
  932. extension: "csv",
  933. requireSamePage: true,
  934. linkTypes: [LinkTypes.DIRECT, LinkTypes.EMBED],
  935. }, runExport);
  936.  
  937. function runExport(status) {
  938. let listing = page.episodeList();
  939. let str = "episode, name, url\n";
  940. for (let episode of status.episodes) {
  941. if (!episode.error) {
  942. str += `${episode.episodeNumber}, ${listing[episode.episodeNumber-1].innerText}, ${episode.functionalLink}\n`;
  943. }
  944. }
  945. return str;
  946. }
  947.  
  948. },{"../ui/page":48,"kgrabber-types":37}],18:[function(require,module,exports){
  949. "use strict";
  950. // src\js\exporters\html.js
  951.  
  952. const { LinkTypes, Exporter } = require("kgrabber-types"),
  953. page = require("../ui/page");
  954.  
  955. module.exports = new Exporter({
  956. name: "html list",
  957. extension: "html",
  958. requireSamePage: true,
  959. linkTypes: [LinkTypes.DIRECT],
  960. }, runExport);
  961.  
  962. function runExport(status) {
  963. let listing = page.episodeList();
  964. let str = "<html>\n <body>\n";
  965. for (let episode of status.episodes) {
  966. if (!episode.error) {
  967. str += `<a href="${episode.functionalLink}" download="${listing[episode.episodeNumber-1].innerText}.mp4">${listing[episode.episodeNumber-1].innerText}</a><br>\n`;
  968. }
  969. }
  970. str += "</body>\n</html>\n";
  971. return str;
  972. }
  973.  
  974. },{"../ui/page":48,"kgrabber-types":37}],19:[function(require,module,exports){
  975. "use strict";
  976. // src\js\exporters\idmbat.js
  977.  
  978. const { LinkTypes, Exporter } = require("kgrabber-types"),
  979. util = require("../util"),
  980. preferenceManager = require("../config/preferenceManager");
  981.  
  982. const preferences = preferenceManager.get();
  983.  
  984. module.exports = new Exporter({
  985. name: "IDM bat file",
  986. extension: "bat",
  987. requireSamePage: true,
  988. linkTypes: [LinkTypes.DIRECT],
  989. }, runExport);
  990.  
  991. function runExport(status) {
  992. let listing = $(".listing a").get().reverse();
  993. let title = util.makeBatSafe(status.title);
  994. let str = getHeader(title);
  995. for (let episode of status.episodes) {
  996. if (!episode.error) {
  997. let epTitle = util.makeBatSafe(listing[episode.episodeNumber - 1].innerText);
  998. if (!preferences.internet_download_manager.keep_title_in_episode_name &&
  999. epTitle.slice(0, title.length) === title) {
  1000. epTitle = epTitle.slice(title.length + 1);
  1001. }
  1002. str += `"%idm%" /n /p "%dir%\\%title%" /f "${epTitle}.mp4" /d "${episode.functionalLink}" %args%\n`;
  1003. }
  1004. }
  1005. return str;
  1006. }
  1007.  
  1008. function getHeader(title) {
  1009. return `::download and double click me!
  1010. @echo off
  1011. set title=${title}
  1012. set idm=${preferences.internet_download_manager.idm_path}
  1013. set args=${preferences.internet_download_manager.arguments}
  1014. set dir=${preferences.internet_download_manager.download_path}
  1015. if not exist "%idm%" echo IDM not found && echo check your IDM path in preferences && pause && goto eof
  1016. mkdir "%title%" > nul
  1017. start "" "%idm%"
  1018. ping localhost -n 2 > nul\n\n`;
  1019. }
  1020.  
  1021. },{"../config/preferenceManager":7,"../util":55,"kgrabber-types":37}],20:[function(require,module,exports){
  1022. "use strict";
  1023. // src\js\exporters\index.js
  1024.  
  1025. const exporters = [
  1026. require("./list"),
  1027. require("./m3u8"),
  1028. require("./json"),
  1029. require("./html"),
  1030. require("./csv"),
  1031. require("./aria2c"),
  1032. require("./idmbat"),
  1033. ];
  1034.  
  1035. exports.all = () =>
  1036. exporters;
  1037.  
  1038. exports.available = (linkType, samePage) =>
  1039. exporters.filter((exporter) =>
  1040. filter(exporter, linkType, samePage)
  1041. );
  1042.  
  1043. exports.sorted = (linkType, samePage) =>
  1044. exporters.map((exporter) => {
  1045. return { available: filter(exporter, linkType, samePage), exporter };
  1046. })
  1047. .sort((a, b) => b.available - a.available);
  1048.  
  1049. exports.add = (...newExporters) => {
  1050. exporters.push(...newExporters);
  1051. };
  1052.  
  1053. function filter(exporter, linkType, samePage) {
  1054. if (!exporter.linkTypes.includes(linkType)) {
  1055. return false;
  1056. }
  1057. if (exporter.requireSamePage && !samePage) {
  1058. return false;
  1059. }
  1060. return true;
  1061. }
  1062.  
  1063. },{"./aria2c":16,"./csv":17,"./html":18,"./idmbat":19,"./json":21,"./list":22,"./m3u8":23}],21:[function(require,module,exports){
  1064. "use strict";
  1065. // src\js\exporters\json.js
  1066.  
  1067. const { LinkTypes, Exporter } = require("kgrabber-types"),
  1068. page = require("../ui/page");
  1069.  
  1070. module.exports = new Exporter({
  1071. name: "json",
  1072. extension: "json",
  1073. requireSamePage: true,
  1074. linkTypes: [LinkTypes.DIRECT, LinkTypes.EMBED],
  1075. }, runExport);
  1076.  
  1077. function runExport(status) {
  1078. let listing = page.episodeList();
  1079. let json = {
  1080. version: "2.0",
  1081. scriptVersion: GM_info.script.version,
  1082. episodes: [],
  1083. url: status.url,
  1084. title: status.title,
  1085. serverID: status.serverID,
  1086. linkType: status.linkType,
  1087. };
  1088. for (let episode of status.episodes) {
  1089. json.episodes.push({
  1090. grabbedLink: episode.grabbedLink,
  1091. processedLink: episode.processedLink,
  1092. error: episode.error,
  1093. episodeNumber: episode.episodeNumber,
  1094. name: listing[episode.episodeNumber - 1].innerText,
  1095. });
  1096. }
  1097. return JSON.stringify(json);
  1098. }
  1099.  
  1100. },{"../ui/page":48,"kgrabber-types":37}],22:[function(require,module,exports){
  1101. "use strict";
  1102. // src\js\exporters\list.js
  1103.  
  1104. const { LinkTypes, Exporter } = require("kgrabber-types");
  1105.  
  1106. module.exports = new Exporter({
  1107. name: "list",
  1108. extension: "txt",
  1109. requireSamePage: false,
  1110. linkTypes: [LinkTypes.DIRECT, LinkTypes.EMBED],
  1111. }, runExport);
  1112.  
  1113. function runExport(status) {
  1114. let str = "";
  1115. for (let episode of status.episodes) {
  1116. if (!episode.error) {
  1117. str += episode.functionalLink + "\n";
  1118. }
  1119. }
  1120. return str;
  1121. }
  1122.  
  1123. },{"kgrabber-types":37}],23:[function(require,module,exports){
  1124. "use strict";
  1125. // src\js\exporters\m3u8.js
  1126.  
  1127. const { LinkTypes, Exporter } = require("kgrabber-types"),
  1128. page = require("../ui/page");
  1129.  
  1130. module.exports = new Exporter({
  1131. name: "m3u8 playlist",
  1132. extension: "m3u8",
  1133. requireSamePage: true,
  1134. linkTypes: [LinkTypes.DIRECT],
  1135. }, runExport);
  1136.  
  1137. function runExport(status) {
  1138. let listing = page.episodeList();
  1139. let str = "#EXTM3U\n";
  1140. for (let episode of status.episodes) {
  1141. if (!episode.error) {
  1142. str += `#EXTINF:0,${listing[episode.episodeNumber-1].innerText}\n${episode.functionalLink}\n`;
  1143. }
  1144. }
  1145. return str;
  1146. }
  1147.  
  1148. },{"../ui/page":48,"kgrabber-types":37}],24:[function(require,module,exports){
  1149. "use strict";
  1150. // generated file, provides contents of src\html
  1151. // src\html\captchaModal.html
  1152. exports[`captchaModal`] = `<div class="KG-captchaModal-container container" style="display: none;">
  1153. <div class="KG-captchaModal bigBarContainer">
  1154. <div class="barTitle">
  1155. <div class="KG-dialog-title">
  1156. Captcha <span id="KG-captchaModal-status"></span>
  1157. </div>
  1158. </div>
  1159. <div class="barContent">
  1160. <div class="arrow-general">
  1161. &nbsp;</div>
  1162. <div>
  1163. <div class="KG-captchaModal-description-header">
  1164. </div>
  1165. <div class="KG-captchaModal-image-container">
  1166. </div>
  1167. </div>
  1168. </div>
  1169. </div>
  1170. </div>
  1171. `;
  1172. // src\html\linkDisplay.html
  1173. exports[`linkDisplay`] = `<div class="bigBarContainer" id="KG-linkdisplay" style="display: none;">
  1174. <div class="barTitle">
  1175. <div class="KG-dialog-title">
  1176. Extracted Links
  1177. </div>
  1178. <span class="KG-dialog-close">
  1179. &#10060; &nbsp;
  1180. </span>
  1181. </div>
  1182. <div class="barContent">
  1183. <div class="arrow-general">
  1184. &nbsp;</div>
  1185. <div id="KG-linkdisplay-text"></div>
  1186. <div class="KG-button-container" id="KG-action-container">
  1187. <select id="KG-linkdisplay-export-dropdown"></select>
  1188. </div>
  1189. <div id="KG-linkdisplay-export" style="display: none;">
  1190. <textarea id="KG-linkdisplay-export-text" spellcheck="false"></textarea>
  1191. <div class="KG-button-container">
  1192. <a id="KG-linkdisplay-export-download">
  1193. <input type="button" value="Download" class="KG-button right">
  1194. </a>
  1195. </div>
  1196. </div>
  1197. </div>
  1198. </div>
  1199. `;
  1200. // src\html\preferences.html
  1201. exports[`preferences`] = `<div class="bigBarContainer" id="KG-preferences" style="display: none;">
  1202. <div class="barTitle">
  1203. <div class="KG-dialog-title">
  1204. Preferences
  1205. </div>
  1206. <span class="KG-dialog-close">
  1207. &#10060; &nbsp;
  1208. </span>
  1209. </div>
  1210. <div class="barContent">
  1211. <div class="arrow-general">
  1212. &nbsp;</div>
  1213. <div id="KG-preferences-container-outer">
  1214. </div>
  1215. <div class="KG-button-container">
  1216. <input type="button" value="Reset to Defaults" class="KG-button left" id="KG-preferences-reset">
  1217. <a class="KG-button left" href="https://github.com/thorio/KGrabber/wiki/Preferences" target="blank">Help</a>
  1218. <input type="button" value="Save" class="KG-button float-right" id="KG-preferences-save">
  1219. </div>
  1220. </div>
  1221. </div>
  1222. `;
  1223. // src\html\widget.html
  1224. exports[`widget`] = `<div class="clear2">
  1225. </div>
  1226. <div class="rightBox" id="KG-opts-widget">
  1227. <div class="barTitle">
  1228. KGrabber
  1229. <button class="KG-preferences-button" title="Settings"></button>
  1230. </div>
  1231. <div class="barContent">
  1232. <div class="arrow-general">
  1233. &nbsp;
  1234. </div>
  1235. <select id="KG-widget-server">
  1236. </select>
  1237. <p>
  1238. from
  1239. <input type="number" id="KG-input-from" class="KG-widget-episode" value=1 min=1> to
  1240. <input type="number" id="KG-input-to" class="KG-widget-episode" min=1>
  1241. </p>
  1242. <div class="KG-button-container">
  1243. <input type="button" class="KG-button" id="KG-input-start" value="Extract Links">
  1244. </div>
  1245. </div>
  1246. </div>
  1247. `;
  1248. },{}],25:[function(require,module,exports){
  1249. "use strict";
  1250. // src\js\main.js
  1251. const config = require("./config"),
  1252. { log } = require("./util"),
  1253. steps = require("./steps"),
  1254. ui = require("./ui"),
  1255. statusManager = require("./statusManager"),
  1256. page = require("./ui/page"),
  1257. pluginLoader = require("./pluginLoader");
  1258.  
  1259. pluginLoader.load();
  1260.  
  1261. const status = statusManager.get(),
  1262. site = config.sites.current();
  1263.  
  1264. if (site) {
  1265. if (site.onContentPath(page.location.pathname)) {
  1266. ui.injectAll();
  1267. site.applyPatch();
  1268. }
  1269.  
  1270. if (status.func) {
  1271. steps.execute(status.func, status, site);
  1272. }
  1273. } else {
  1274. log.err(`'${page.location.hostname}' is not supported`);
  1275. }
  1276.  
  1277. },{"./config":6,"./pluginLoader":38,"./statusManager":41,"./steps":44,"./ui":46,"./ui/page":48,"./util":55}],26:[function(require,module,exports){
  1278. // src\js\node_modules\kgrabber-plugin\PluginContext.js
  1279.  
  1280. module.exports = class PluginContext {
  1281. constructor({ addActionsFunc, addSitesFunc, addExportersFunc, addStepsFunc, ui, preferences, statusManager }) {
  1282. this._addActionsFunc = addActionsFunc;
  1283. this._addSitesFunc = addSitesFunc;
  1284. this._addExportersFunc = addExportersFunc;
  1285. this._addStepsFunc = addStepsFunc;
  1286. this.ui = ui;
  1287. this.preferences = preferences;
  1288. this.statusManager = statusManager;
  1289. Object.freeze(this);
  1290. }
  1291.  
  1292. addActions(...actions) {
  1293. this._addActionsFunc(...actions);
  1294. }
  1295.  
  1296. addSites(...sites) {
  1297. this._addSitesFunc(...sites);
  1298. }
  1299.  
  1300. addExporters(...exporters) {
  1301. this._addExportersFunc(...exporters);
  1302. }
  1303.  
  1304. addSteps(steps) {
  1305. this._addStepsFunc(steps);
  1306. }
  1307. };
  1308.  
  1309. },{}],27:[function(require,module,exports){
  1310. // src\js\node_modules\kgrabber-types\Action.js
  1311.  
  1312. module.exports = class Action {
  1313. constructor(name, { availableFunc, executeFunc, automatic = false }) {
  1314. this.name = name;
  1315. this.automatic = automatic;
  1316. this._executeFunc = executeFunc;
  1317. this._availableFunc = availableFunc;
  1318. Object.freeze(this);
  1319. }
  1320.  
  1321. isAvailable(status) {
  1322. return this._availableFunc(this, status);
  1323. }
  1324.  
  1325. invoke(status, setProgress) {
  1326. return this._executeFunc(status, setProgress);
  1327. }
  1328. };
  1329.  
  1330. },{}],28:[function(require,module,exports){
  1331. // src\js\node_modules\kgrabber-types\Captcha.js
  1332. module.exports = class Captcha {
  1333. constructor(texts, images) {
  1334. this.texts = texts;
  1335. this.images = images;
  1336. Object.seal(this);
  1337. }
  1338. };
  1339.  
  1340. },{}],29:[function(require,module,exports){
  1341. // src\js\node_modules\kgrabber-types\Dictionary.js
  1342. module.exports = class Dictionary {
  1343. constructor(objects = []) {
  1344. this._data = {};
  1345. this.add(...objects);
  1346. Object.freeze(this);
  1347. }
  1348.  
  1349. add(...objects) {
  1350. for (let object of objects) {
  1351. if (this._data[object.identifier]) {
  1352. throw new Error(`Duplicate key '${object.identifier}'`);
  1353. }
  1354. this._data[object.identifier] = object;
  1355. }
  1356. }
  1357.  
  1358. remove(key) {
  1359. delete this._data[key];
  1360. }
  1361.  
  1362. get(key) {
  1363. return this._data[key];
  1364. }
  1365.  
  1366. *[Symbol.iterator]() {
  1367. for (let i in this._data) {
  1368. yield this._data[i];
  1369. }
  1370. }
  1371. };
  1372.  
  1373. },{}],30:[function(require,module,exports){
  1374. // src\js\node_modules\kgrabber-types\Episode.js
  1375.  
  1376. module.exports = class Episode {
  1377. constructor(episodeNumber, kissLink) {
  1378. this.grabbedLink = "";
  1379. this.processedLink = "";
  1380. this.displayOverride = "";
  1381. this.kissLink = kissLink;
  1382. this.error = "";
  1383. this.episodeNumber = episodeNumber;
  1384. Object.seal(this);
  1385. }
  1386.  
  1387. get functionalLink() {
  1388. return this.processedLink || this.grabbedLink;
  1389. }
  1390.  
  1391. get displayLink() {
  1392. if (this.error) {
  1393. return `error: ${this.error}`;
  1394. }
  1395. if (this.displayOverride) {
  1396. return `{${this.displayOverride}}`;
  1397. }
  1398. return this.processedLink || this.grabbedLink;
  1399. }
  1400. };
  1401.  
  1402. },{}],31:[function(require,module,exports){
  1403. // src\js\node_modules\kgrabber-types\Exporter.js
  1404.  
  1405. module.exports = class Exporter {
  1406. constructor({ name, extension, requireSamePage, linkTypes }, func) {
  1407. this.name = name;
  1408. this.extension = extension;
  1409. this.requireSamePage = requireSamePage;
  1410. this.linkTypes = linkTypes;
  1411. this._export = func;
  1412. Object.freeze(this);
  1413. }
  1414.  
  1415. export (status) {
  1416. return this._export(status);
  1417. }
  1418. };
  1419.  
  1420. },{}],32:[function(require,module,exports){
  1421. // src\js\node_modules\kgrabber-types\LinkTypes.js
  1422. module.exports = Object.freeze({
  1423. EMBED: "embed",
  1424. DIRECT: "direct",
  1425. OVELWRAP: "ovelwrap",
  1426. HLS: "hls",
  1427. });
  1428.  
  1429. },{}],33:[function(require,module,exports){
  1430. // src\js\node_modules\kgrabber-types\Logger.js
  1431. module.exports = class Logger {
  1432. constructor(name, { color = "#000", backgroundColor = "#fff" } = {}) {
  1433. this.name = name;
  1434. this.css = `color: ${color}; background-color: ${backgroundColor}; padding: 0 5px; border-radius: 3px;`;
  1435. }
  1436.  
  1437. info(...obj) {
  1438. console.info(`%c${this.name}`, this.css, ...obj);
  1439. }
  1440.  
  1441. log(...obj) {
  1442. console.log(`%c${this.name}`, this.css, ...obj);
  1443. }
  1444.  
  1445. warn(...obj) {
  1446. console.warn(`%c${this.name}`, this.css, ...obj);
  1447. }
  1448.  
  1449. err(...obj) {
  1450. console.error(`%c${this.name}`, this.css, ...obj);
  1451. }
  1452.  
  1453. debug(...obj) {
  1454. console.debug(`%c${this.name}`, this.css, ...obj);
  1455. }
  1456. };
  1457.  
  1458. },{}],34:[function(require,module,exports){
  1459. // src\js\node_modules\kgrabber-types\Server.js
  1460. module.exports = class Server {
  1461. constructor(identifier, { regex, captureGroup, trimQuotes, name, linkType, customStep, experimentalStep }) {
  1462. this.identifier = identifier;
  1463. this.regex = regex;
  1464. this.captureGroup = captureGroup || 0;
  1465. this.trimQuotes = trimQuotes == undefined ? true : trimQuotes;
  1466. this.name = name;
  1467. this.linkType = linkType;
  1468. this.customStep = customStep;
  1469. this.experimentalStep = experimentalStep;
  1470. Object.freeze(this);
  1471. }
  1472.  
  1473. getEffectiveStep(defaultStep, allowExperimental, allowCustom) {
  1474. return allowExperimental && this.experimentalStep ||
  1475. allowCustom && this.customStep ||
  1476. defaultStep;
  1477. }
  1478.  
  1479. findLink(html) {
  1480. let result = html.match(this.regex);
  1481. if (result) {
  1482. var link = result[this.captureGroup];
  1483. if (this.trimQuotes) {
  1484. link = link.split('"')[1];
  1485. }
  1486. return link;
  1487. } else {
  1488. return undefined;
  1489. }
  1490. }
  1491. };
  1492.  
  1493. },{}],35:[function(require,module,exports){
  1494. // src\js\node_modules\kgrabber-types\Site.js
  1495.  
  1496. module.exports = class Site {
  1497. constructor(hostname, { contentPath, noCaptchaServer, buttonColor, buttonTextColor, servers, patches = {} }) {
  1498. this.hostname = hostname;
  1499. this.contentPath = new RegExp(`^/${contentPath}/[^/]+/?$`);
  1500. this.episodePath = new RegExp(`^/${contentPath}/[^/]+/[^/]+/?$`);
  1501. this.noCaptchaServer = noCaptchaServer;
  1502. this.buttonColor = buttonColor;
  1503. this.buttonTextColor = buttonTextColor;
  1504. this.servers = servers;
  1505. this.patches = patches;
  1506. Object.freeze(this);
  1507. }
  1508.  
  1509. get identifier() {
  1510. return this.hostname;
  1511. }
  1512.  
  1513. onContentPath(pathname) {
  1514. return this.contentPath.test(pathname);
  1515. }
  1516.  
  1517. onEpisodePath(pathname) {
  1518. return this.episodePath.test(pathname);
  1519. }
  1520.  
  1521. applyPatch(uiElement = "page") {
  1522. if (this.patches[uiElement]) this.patches[uiElement]();
  1523. }
  1524. };
  1525.  
  1526. },{}],36:[function(require,module,exports){
  1527. // src\js\node_modules\kgrabber-types\Status.js
  1528. const Episode = require("kgrabber-types/Episode");
  1529.  
  1530. module.exports = class Status {
  1531. constructor() {
  1532. this._reset();
  1533. Object.seal(this);
  1534. }
  1535.  
  1536. _reset() {
  1537. this.episodes = [];
  1538. this.current = 0;
  1539. this.automaticDone = false;
  1540. this.hasReset = false;
  1541. this.func = "";
  1542. this.url = "";
  1543. this.title = "";
  1544. this.serverID = "";
  1545. this.linkType = "";
  1546. }
  1547.  
  1548. initialize({ url, title, serverID, linkType }) {
  1549. this._reset();
  1550. this.url = url;
  1551. this.title = title;
  1552. this.serverID = serverID;
  1553. this.linkType = linkType;
  1554. }
  1555.  
  1556. clear() {
  1557. this._reset();
  1558. }
  1559.  
  1560. serialize() {
  1561. return JSON.stringify(this);
  1562. }
  1563.  
  1564. static deserialize(json) {
  1565. let obj = JSON.parse(json);
  1566. for (let i in obj.episodes) {
  1567. obj.episodes[i] = Object.assign(new Episode(), obj.episodes[i]);
  1568. }
  1569. return Object.assign(new this, obj);
  1570. }
  1571. };
  1572.  
  1573. },{"kgrabber-types/Episode":30}],37:[function(require,module,exports){
  1574. // src\js\node_modules\kgrabber-types\index.js
  1575. module.exports = {
  1576. Action: require("./Action"),
  1577. Captcha: require("./Captcha"),
  1578. Dictionary: require("./Dictionary"),
  1579. Episode: require("./Episode"),
  1580. Exporter: require("./Exporter"),
  1581. LinkTypes: require("./LinkTypes"),
  1582. Logger: require("./Logger"),
  1583. Server: require("./Server"),
  1584. Site: require("./Site"),
  1585. Status: require("./Status"),
  1586. };
  1587.  
  1588. },{"./Action":27,"./Captcha":28,"./Dictionary":29,"./Episode":30,"./Exporter":31,"./LinkTypes":32,"./Logger":33,"./Server":34,"./Site":35,"./Status":36}],38:[function(require,module,exports){
  1589. "use strict";
  1590. // src\js\pluginLoader.js
  1591. const util = require("./util"),
  1592. PluginContext = require("kgrabber-plugin/PluginContext"),
  1593. { preferenceManager, sites } = require("./config"),
  1594. statusManager = require("./statusManager"),
  1595. actions = require("./actions"),
  1596. exporters = require("./exporters"),
  1597. steps = require("./steps"),
  1598. version = require("./pluginVersion"),
  1599. semverSatisfies = require("semver/functions/satisfies"),
  1600. ui = require("./ui/pluginExposed");
  1601.  
  1602. const $ = unsafeWindow.$,
  1603. applicationName = "KGrabberPlugin",
  1604. allowedPluginsKey = "allowedPlugins",
  1605. preferences = preferenceManager.get();
  1606.  
  1607. let allowedPlugins;
  1608.  
  1609. exports.load = () => {
  1610. if (!$) {
  1611. util.log.err(`jquery not present on the page, can't load plugins`);
  1612. return;
  1613. }
  1614. loadPlugins();
  1615. };
  1616.  
  1617. function loadPlugins() {
  1618. getAllowedPlugins();
  1619. let foundPlugins = discoverPlugins();
  1620. if (foundPlugins.length > 0) {
  1621. let context = new PluginContext({
  1622. addActionsFunc: actions.add,
  1623. addSitesFunc: sites.add,
  1624. addExportersFunc: exporters.add,
  1625. addStepsFunc: steps.add,
  1626. ui,
  1627. preferences,
  1628. statusManager,
  1629. });
  1630.  
  1631. for (let plugin of foundPlugins) {
  1632. let expectedVersion = `^${plugin.version}`;
  1633. if (!plugin.version || !semverSatisfies(version, expectedVersion)) {
  1634. util.log.err(`plugin "${plugin.pluginID}" could not be loaded due to version mismatch: expected "${expectedVersion}", got "${version}"`);
  1635. continue;
  1636. }
  1637. if (!allowedPlugins.includes(plugin.pluginID)) {
  1638. if (confirm(`allow plugin '${plugin.pluginID}'?`)) {
  1639. allowPlugin(plugin.pluginID);
  1640. } else {
  1641. continue;
  1642. }
  1643. }
  1644. loadPlugin(plugin.pluginID, context);
  1645. }
  1646. }
  1647. }
  1648.  
  1649. function discoverPlugins() {
  1650. let foundPlugins = [];
  1651.  
  1652. $(document).on(`${applicationName}/DiscoverResponse`, (e, { pluginID, version }) => {
  1653. foundPlugins.push({ pluginID, version });
  1654. });
  1655. $(document).trigger(`${applicationName}/DiscoverRequest`);
  1656. return foundPlugins;
  1657. }
  1658.  
  1659. function loadPlugin(pluginID, context) {
  1660. util.log.debug(`loading plugin '${pluginID}'`);
  1661. $(document).trigger(`${applicationName}/LoadPlugin-${pluginID}`, context);
  1662. }
  1663.  
  1664. function getAllowedPlugins() {
  1665. try {
  1666. allowedPlugins = JSON.parse(GM_getValue(allowedPluginsKey));
  1667. } catch (e) {
  1668. allowedPlugins = [];
  1669. saveAllowedPlugins();
  1670. }
  1671. }
  1672.  
  1673. function saveAllowedPlugins() {
  1674. GM_setValue(allowedPluginsKey, JSON.stringify(allowedPlugins));
  1675. }
  1676.  
  1677. function allowPlugin(pluginID) {
  1678. allowedPlugins.push(pluginID);
  1679. saveAllowedPlugins();
  1680. }
  1681.  
  1682. },{"./actions":3,"./config":6,"./exporters":20,"./pluginVersion":39,"./statusManager":41,"./steps":44,"./ui/pluginExposed":50,"./util":55,"kgrabber-plugin/PluginContext":26,"semver/functions/satisfies":70}],39:[function(require,module,exports){
  1683. "use strict";
  1684. // version of ./src/js/node_modules/kgrabber-plugin
  1685. module.exports = "1.1.1";
  1686. },{}],40:[function(require,module,exports){
  1687. "use strict";
  1688. // src\js\start.js
  1689. const config = require("./config"),
  1690. util = require("./util"),
  1691. steps = require("./steps"),
  1692. page = require("./ui/page"),
  1693. statusManager = require("./statusManager"),
  1694. { Episode } = require("kgrabber-types");
  1695.  
  1696. const preferences = config.preferenceManager.get(),
  1697. status = statusManager.get(),
  1698. defaultStep = "defaultBegin";
  1699.  
  1700. module.exports = (start, end, serverID) => {
  1701. let site = config.sites.current();
  1702. let server = site.servers.get(serverID);
  1703. statusManager.initialize({
  1704. title: page.title(),
  1705. serverID,
  1706. linkType: server.linkType,
  1707. });
  1708. status.episodes = getEpisodes(start, end);
  1709. status.func = server.getEffectiveStep(defaultStep, preferences.compatibility.enable_experimental_grabbers, !preferences.compatibility.force_default_grabber);
  1710.  
  1711. statusManager.save();
  1712. steps.execute(status.func, status, site);
  1713. $("html, body").animate({ scrollTop: 0 }, "slow");
  1714. };
  1715.  
  1716. function getEpisodes(start, end) {
  1717. let episodes = [];
  1718. util.for(page.episodeList(), (i, obj) => {
  1719. episodes.push(new Episode(i + 1, obj.href));
  1720. }, {
  1721. min: start,
  1722. max: end,
  1723. });
  1724.  
  1725. return episodes;
  1726. }
  1727.  
  1728. },{"./config":6,"./statusManager":41,"./steps":44,"./ui/page":48,"./util":55,"kgrabber-types":37}],41:[function(require,module,exports){
  1729. "use strict";
  1730. // src\js\statusManager.js
  1731. const log = require("./util").log,
  1732. page = require("./ui/page"),
  1733. { Status } = require("kgrabber-types");
  1734.  
  1735. const propName = "KG-status";
  1736.  
  1737. let status;
  1738.  
  1739. exports.get = () => {
  1740. if (status === undefined) {
  1741. status = load();
  1742. }
  1743. return status;
  1744. };
  1745.  
  1746. exports.save = () => {
  1747. sessionStorage[propName] = JSON.stringify(status);
  1748. };
  1749.  
  1750. exports.clear = () => {
  1751. status.clear();
  1752. sessionStorage.removeItem(propName);
  1753. };
  1754.  
  1755. exports.initialize = ({ title, serverID, linkType } = {}) => {
  1756. return status.initialize({
  1757. url: page.href,
  1758. title,
  1759. serverID,
  1760. linkType,
  1761. });
  1762. };
  1763.  
  1764. function load() {
  1765. let json = sessionStorage[propName];
  1766. if (json) {
  1767. try {
  1768. return Status.deserialize(json);
  1769. } catch (error) {
  1770. log.err("unable to parse JSON", { error, json });
  1771. }
  1772. }
  1773.  
  1774. return new Status();
  1775. }
  1776.  
  1777. },{"./ui/page":48,"./util":55,"kgrabber-types":37}],42:[function(require,module,exports){
  1778. "use strict";
  1779. // src\js\steps\captchaModal.js
  1780.  
  1781. const util = require("../util"),
  1782. statusManager = require("../statusManager"),
  1783. config = require("../config"),
  1784. linkDisplay = require("../ui/linkDisplay"),
  1785. captchaModal = require("../ui/captchaModal"),
  1786. { Captcha } = require("kgrabber-types");
  1787.  
  1788. exports.modalBegin = async (status) => {
  1789. linkDisplay.show();
  1790. linkDisplay.showSpinner();
  1791. let progress = 0;
  1792. let func = async ( episode) => {
  1793. let html = await doCaptcha(`${episode.kissLink}&s=${status.serverID}`);
  1794. getLink(html, episode, status.serverID);
  1795. progress++;
  1796. setStatusText(`${progress}/${promises.length}`);
  1797. };
  1798. let promises = [];
  1799. util.for(status.episodes, (i, episode) => {
  1800. promises.push(func(episode));
  1801. });
  1802. setStatusText(`0/${promises.length}`);
  1803. await Promise.all(promises);
  1804. status.func = "defaultFinished";
  1805. statusManager.save();
  1806. linkDisplay.load();
  1807. };
  1808.  
  1809. function setStatusText(str) {
  1810. linkDisplay.setSpinnerText(str);
  1811. captchaModal.setStatusText(str);
  1812. }
  1813.  
  1814. async function doCaptcha(url) {
  1815. while (true) {
  1816. let html = (await util.ajax.get(url)).response;
  1817. let $form = $(html).find("form#formVerify1");
  1818. if ($form.length == 0) {
  1819. return html;
  1820. }
  1821. let texts = [];
  1822. $form.find("span:lt(2)").each((_i, obj) => texts.push(obj.innerText.replace(/[ \n]*(\w)/, "$1")));
  1823. let images = [];
  1824. $form.find("img").each((i, obj) => images.push(obj.src));
  1825. let answerCap = (await captchaModal.queue(new Captcha(texts, images))).join(",") + ",";
  1826. let response = (await util.ajax.post("/Special/AreYouHuman2", util.urlEncode({ reUrl: url, answerCap }), { "content-type": "application/x-www-form-urlencoded" })).response;
  1827. if (isCaptchaFail(response)) {
  1828. continue;
  1829. }
  1830. return response;
  1831. }
  1832. }
  1833.  
  1834. function getLink(html, episode, serverID) {
  1835. let link = config.sites.current().servers.get(serverID).findLink(html);
  1836. if (link) {
  1837. episode.grabbedLink = link;
  1838. } else {
  1839. episode.error = "no link found";
  1840. }
  1841. }
  1842.  
  1843. function isCaptchaFail(html) {
  1844. let lowerCase = html.toLowerCase();
  1845. return lowerCase.includes("wrong answer") || lowerCase.includes("areyouhuman2");
  1846. }
  1847.  
  1848. },{"../config":6,"../statusManager":41,"../ui/captchaModal":45,"../ui/linkDisplay":47,"../util":55,"kgrabber-types":37}],43:[function(require,module,exports){
  1849. "use strict";
  1850. // src\js\steps\default.js
  1851.  
  1852. const statusManager = require("../statusManager"),
  1853. config = require("../config"),
  1854. linkDisplay = require("../ui/linkDisplay"),
  1855. page = require("../ui/page");
  1856.  
  1857. exports.defaultBegin = (status) => {
  1858. status.func = "defaultGetLink";
  1859. statusManager.save();
  1860. page.href = status.episodes[status.current].kissLink + `&s=${status.serverID}`;
  1861. };
  1862.  
  1863. exports.defaultGetLink = (status) => {
  1864. if (!config.sites.current().onEpisodePath(page.location.pathname)) {
  1865. return;
  1866. }
  1867. let episode = status.episodes[status.current];
  1868. let link = config.sites.current().servers.get(status.serverID).findLink(document.body.innerHTML);
  1869. if (link) {
  1870. episode.grabbedLink = link;
  1871. } else {
  1872. episode.error = "no link found";
  1873. }
  1874.  
  1875. status.current++;
  1876. if (status.current >= status.episodes.length) {
  1877. status.func = "defaultFinished";
  1878. page.href = status.url;
  1879. } else {
  1880. page.href = status.episodes[status.current].kissLink + `&s=${status.serverID}`;
  1881. }
  1882. statusManager.save();
  1883. };
  1884.  
  1885. exports.defaultFinished = (status, site) => {
  1886. if (site.onContentPath(page.location.pathname)) {
  1887. linkDisplay.load();
  1888. }
  1889. };
  1890.  
  1891. },{"../config":6,"../statusManager":41,"../ui/linkDisplay":47,"../ui/page":48}],44:[function(require,module,exports){
  1892. "use strict";
  1893. // src\js\steps\index.js
  1894.  
  1895. const { log } = require("../util");
  1896.  
  1897. const steps = Object.assign({},
  1898. require("./default"),
  1899. require("./captchaModal")
  1900. );
  1901.  
  1902. exports.execute = (stepName, status, site) => {
  1903. if (steps[stepName]) {
  1904. steps[stepName](status, site);
  1905. } else {
  1906. log.err(`tried executing invalid step '${stepName}'`, { steps });
  1907. }
  1908. };
  1909.  
  1910. exports.add = (newSteps) => {
  1911. Object.assign(steps, newSteps);
  1912. };
  1913.  
  1914. },{"../util":55,"./captchaModal":42,"./default":43}],45:[function(require,module,exports){
  1915. "use strict";
  1916. // src\js\ui\captchaModal.js
  1917.  
  1918. const util = require("../util"),
  1919. html = require("../html"),
  1920. page = require("./page"),
  1921. { sites } = require("../config");
  1922.  
  1923. let queue = [];
  1924. let injected = false;
  1925.  
  1926. function inject() {
  1927. $("body").append(html.captchaModal);
  1928. sites.current().applyPatch("captchaModal");
  1929. injected = true;
  1930. if (!$(".KG-captchaModal").length) util.log.err(new Error("captchaModal not injected"));
  1931. }
  1932.  
  1933. exports.queue = (captcha) => {
  1934. return new Promise((resolve) => {
  1935. queue.push({ captcha, resolve });
  1936. if (queue.length == 1) {
  1937. show();
  1938. queueNext();
  1939. }
  1940. });
  1941. };
  1942.  
  1943. function queueNext() {
  1944. let current = queue[0];
  1945. clear();
  1946. load(current.captcha, current.resolve);
  1947. }
  1948.  
  1949. function queuePop() {
  1950. queue.splice(0, 1);
  1951. if (queue.length == 0) {
  1952. hide();
  1953. } else {
  1954. queueNext();
  1955. }
  1956. }
  1957.  
  1958. exports.setStatusText = (text) => {
  1959. $("#KG-captchaModal-status").text(text);
  1960. };
  1961.  
  1962. function show() {
  1963. if (!injected) inject();
  1964. $(".KG-captchaModal-container").fadeIn("fast");
  1965. page.scroll(false);
  1966. }
  1967.  
  1968. function hide() {
  1969. $(".KG-captchaModal-container").fadeOut("fast");
  1970. page.scroll(true);
  1971. }
  1972.  
  1973. function clear() {
  1974. $(".KG-captchaModal-description-header").empty();
  1975. $(".KG-captchaModal-image-container").empty();
  1976. }
  1977.  
  1978. function load(captcha, resolve) {
  1979. for (let text of captcha.texts) {
  1980. $("<span>")
  1981. .text(text)
  1982. .appendTo(".KG-captchaModal-description-header");
  1983. }
  1984. for (let i in captcha.images) {
  1985. $("<img>")
  1986. .attr({
  1987. "src": captcha.images[i],
  1988. "data-index": i,
  1989. })
  1990. .click(
  1991. (e) => {
  1992. toggleImage(e.target, captcha, resolve);
  1993. })
  1994. .appendTo(".KG-captchaModal-image-container");
  1995. }
  1996. applyColors();
  1997. }
  1998.  
  1999. async function toggleImage(image, captcha, resolve) {
  2000. $(image).toggleClass("active");
  2001. let $activeImages = $(".KG-captchaModal-image-container img.active");
  2002. if ($activeImages.length >= 2) {
  2003. let activeIndices = [];
  2004. $activeImages.each(
  2005. (i, obj) => void activeIndices.push(Number(obj.dataset.index))
  2006. );
  2007.  
  2008. resolve(activeIndices);
  2009. queuePop();
  2010. }
  2011. }
  2012.  
  2013. function applyColors() {
  2014.  
  2015. }
  2016.  
  2017. },{"../config":6,"../html":24,"../util":55,"./page":48}],46:[function(require,module,exports){
  2018. "use strict";
  2019. // src\js\ui\index.js
  2020. const widget = require("./widget"),
  2021. pageWidgets = require("./pageWidgets"),
  2022. css = require("../css");
  2023.  
  2024. function injectCss() {
  2025. $(document.head).append(`<style>${css}</style>`);
  2026. }
  2027.  
  2028. exports.injectAll = () => {
  2029. injectCss();
  2030. widget.show();
  2031. pageWidgets.injectEpisodeListWidgets();
  2032. };
  2033.  
  2034. },{"../css":15,"./pageWidgets":49,"./widget":53}],47:[function(require,module,exports){
  2035. "use strict";
  2036. // src\js\ui\linkDisplay.js
  2037.  
  2038. const shared = require("./shared"),
  2039. exporters = require("../exporters"),
  2040. util = require("../util"),
  2041. html = require("../html"),
  2042. actions = require("../actions"),
  2043. statusManager = require("../statusManager"),
  2044. preferenceManager = require("../config/preferenceManager"),
  2045. page = require("./page"),
  2046. { sites } = require("../config");
  2047.  
  2048. const status = statusManager.get(),
  2049. preferences = preferenceManager.get();
  2050. let injected = false;
  2051.  
  2052. function inject() {
  2053. $("#leftside").prepend(html.linkDisplay);
  2054. setHandlers();
  2055. sites.current().applyPatch("linkDisplay");
  2056. injected = true;
  2057. if (!$("#KG-linkdisplay").length) util.log.err(new Error("linkDisplay not injected"));
  2058. }
  2059.  
  2060. let load = exports.load = () => {
  2061. show(true);
  2062. setTitle(`Extracted Links | ${status.title}`);
  2063. loadLinks(status.episodes);
  2064. loadExporters(exporters.sorted(status.linkType, status.url == page.href));
  2065. loadActions(actions.available());
  2066.  
  2067. shared.applyColors();
  2068. };
  2069.  
  2070. let show = exports.show = (instant) => {
  2071. if (!injected) inject();
  2072. instant ? $("#KG-linkdisplay").show() : $("#KG-linkdisplay").slideDown();
  2073. };
  2074.  
  2075. let hide = exports.hide = () =>
  2076. $("#KG-linkdisplay").slideUp();
  2077.  
  2078. function setTitle(text) {
  2079. $("#KG-linkdisplay .KG-dialog-title").text(text);
  2080. }
  2081.  
  2082. function loadLinks(episodes) {
  2083. let html = "";
  2084. let padLength = Math.max(2, page.episodeCount().toString().length);
  2085. util.for(episodes, (i, obj) => {
  2086. let num = obj.episodeNumber.toString().padStart(padLength, "0");
  2087. let number = `<div class="KG-linkdisplay-episodenumber">E${num}:</div>`;
  2088. let link = `<a href="${obj.functionalLink}" target="_blank">${obj.displayLink}</a>`;
  2089. if (obj.error || obj.displayOverride) {
  2090. link = obj.displayLink;
  2091. }
  2092. html += `<div class="KG-linkdisplay-row">${number} ${link}</div>`;
  2093. });
  2094. $("#KG-linkdisplay-text").html(`<div class="KG-linkdisplay-table">${html}</div>`);
  2095. }
  2096.  
  2097. function loadActions(actions) {
  2098. $("#KG-action-container .KG-button").remove();
  2099. for (let i in actions) {
  2100. if (actions[i].automatic && !status.hasReset && !preferences.compatibility.disable_automatic_actions) {
  2101. util.defer(() => {
  2102. executeAction(actions[i]);
  2103. });
  2104. } else {
  2105. $(`<input type="button" class="KG-button" value="${actions[i].name}">`)
  2106. .click(() => {
  2107. executeAction(actions[i]);
  2108. })
  2109. .appendTo("#KG-action-container");
  2110. }
  2111. }
  2112. }
  2113.  
  2114. function loadExporters(arr) {
  2115. let $exporters = $("#KG-linkdisplay-export-dropdown");
  2116. $exporters.empty()
  2117. .off("change")
  2118. .change((e) => {
  2119. runExporter(arr[e.target.value].exporter);
  2120. $(e.target).val("");
  2121. })
  2122. .append($("<option>")
  2123. .attr({
  2124. value: "",
  2125. hidden: true,
  2126. })
  2127. .text("Export as")
  2128. );
  2129.  
  2130. for (let i in arr) {
  2131. $("<option>")
  2132. .text(arr[i].exporter.name)
  2133. .attr({
  2134. value: i,
  2135. disabled: !arr[i].available,
  2136. })
  2137. .appendTo($exporters);
  2138. }
  2139. }
  2140.  
  2141. function setHandlers() {
  2142. $("#KG-linkdisplay .KG-dialog-close").click(() => {
  2143. hide();
  2144. statusManager.clear();
  2145. });
  2146. }
  2147.  
  2148. async function executeAction(action) {
  2149. showSpinner();
  2150. await actions.execute(action, setSpinnerText);
  2151. statusManager.save();
  2152. load();
  2153. }
  2154.  
  2155. function runExporter(exporter) {
  2156. let data = exporter.export(status);
  2157. setExportText(data);
  2158. setDownloadFile(data, status.title, exporter.extension);
  2159. showExports();
  2160. }
  2161.  
  2162. let showSpinner = exports.showSpinner = () =>
  2163. $("#KG-linkdisplay-text").html(`<div class="loader">Loading...</div><div id="KG-loader-text"><div>`);
  2164.  
  2165. let setSpinnerText = exports.setSpinnerText = (str) =>
  2166. $("#KG-loader-text").text(str);
  2167.  
  2168. let setExportText = (text) =>
  2169. $("#KG-linkdisplay-export-text").text(text);
  2170.  
  2171. let showExports = () =>
  2172. $("#KG-linkdisplay-export").show();
  2173.  
  2174. function setDownloadFile(data, filename, extension) {
  2175. $("#KG-linkdisplay-export-download").attr({
  2176. href: `data:text/plain;charset=utf-8,${encodeURIComponent(data)}`,
  2177. download: `${filename}.${extension}`,
  2178. });
  2179. }
  2180.  
  2181. },{"../actions":3,"../config":6,"../config/preferenceManager":7,"../exporters":20,"../html":24,"../statusManager":41,"../util":55,"./page":48,"./shared":52}],48:[function(require,module,exports){
  2182. "use strict";
  2183. // src\js\ui\page.js
  2184. const util = require("../util");
  2185.  
  2186. exports.episodeCount = () =>
  2187. $(".listing a").length;
  2188.  
  2189. exports.title = () =>
  2190. $(".bigBarContainer a.bigChar").text();
  2191.  
  2192. exports.noTitle = () =>
  2193. exports.title() == "";
  2194.  
  2195. exports.episodeList = () =>
  2196. $(`.listing a`).get()
  2197. .reverse();
  2198.  
  2199. exports.reload = () =>
  2200. location.reload();
  2201.  
  2202. Object.defineProperty(exports, "href", {
  2203. get: () => location.href,
  2204. set: (href) => { location.href = href; },
  2205. });
  2206.  
  2207. Object.defineProperty(exports, "location", {
  2208. get: () => util.merge({}, location),
  2209. });
  2210.  
  2211. exports.scroll = (enable) => {
  2212. $(document.body).css("overflow", enable ? "" : "hidden");
  2213. };
  2214.  
  2215. },{"../util":55}],49:[function(require,module,exports){
  2216. "use strict";
  2217. // src\js\ui\pageWidgets.js
  2218. const shared = require("./shared"),
  2219. start = require("../start"),
  2220. widget = require("./widget"),
  2221. page = require("./page");
  2222.  
  2223. exports.injectEpisodeListWidgets = () => {
  2224. let epCount = page.episodeCount();
  2225. $(".listing tr:eq(0)").prepend(`<th class="KG-episodelist-header">#</th>`);
  2226. $(".listing tr:gt(1)").each((i, obj) => {
  2227. let episode = epCount - i - 1;
  2228. $(`<input type="button" value="grab" class="KG-episodelist-button">&nbsp;`)
  2229. .click(() => {
  2230. start(episode, episode, widget.getServer());
  2231. })
  2232. .prependTo($(obj).children(":eq(0)"));
  2233. $(`<td class="KG-episodelist-number">${episode + 1}</td>`).prependTo(obj);
  2234. });
  2235.  
  2236. shared.applyColors();
  2237. };
  2238.  
  2239. },{"../start":40,"./page":48,"./shared":52,"./widget":53}],50:[function(require,module,exports){
  2240. "use strict";
  2241. // src\js\ui\pluginExposed.js
  2242. module.exports = {
  2243. captchaModal: require("./captchaModal"),
  2244. linkDisplay: require("./linkDisplay"),
  2245. page: require("./page"),
  2246. };
  2247.  
  2248. },{"./captchaModal":45,"./linkDisplay":47,"./page":48}],51:[function(require,module,exports){
  2249. "use strict";
  2250. // src\js\ui\preferences.js
  2251. const log = require("../util/log"),
  2252. shared = require("./shared"),
  2253. html = require("../html"),
  2254. page = require("./page"),
  2255. { sites, preferenceManager } = require("../config");
  2256.  
  2257. let injected = false;
  2258.  
  2259. exports.show = () => {
  2260. if (!injected) inject();
  2261. $("#KG-preferences").slideDown();
  2262. };
  2263.  
  2264. let hide = exports.hide = () =>
  2265. $("#KG-preferences").slideUp();
  2266.  
  2267. function inject() {
  2268. $("#leftside").prepend(html.preferences);
  2269. setHandlers();
  2270. load(preferenceManager.get());
  2271. sites.current().applyPatch("preferences");
  2272. injected = true;
  2273. }
  2274.  
  2275. let load = (preferences) => {
  2276. for (let i in preferences) {
  2277. let group = preferences[i];
  2278. let $group = $(`<div id="KG-preferences-container"></div>`);
  2279. for (let j in preferences[i]) {
  2280. let html = "";
  2281. switch (typeof group[j]) {
  2282. case "string":
  2283. case "number":
  2284. html = `<div><span>${j.replace(/_/g, " ")}:</span><input type="${typeof group[j]}" value="${group[j]}" class="KG-preferences-input-text right" id="KG-preference-${i}-${j}"></div>`;
  2285. break;
  2286. case "boolean":
  2287. html = `<div><span>${j.replace(/_/g, " ")}:</span><input type="checkbox" ${group[j] ? "checked" : ""} class="KG-preferences-input-checkbox right" id="KG-preference-${i}-${j}"></div>`;
  2288. break;
  2289. default:
  2290. log.err(`unknown type "${typeof group[j]}" of preferences.${i}.${j}`);
  2291. }
  2292. $group.append(html);
  2293. }
  2294. let headerTitle = i.replace(/_/g, " ").replace(/[a-z]+/g, (s) => s.charAt(0).toUpperCase() + s.slice(1));
  2295. $("#KG-preferences-container-outer").append(`<div class="KG-preferences-header KG-bigChar">${headerTitle}</div>`)
  2296. .append($group);
  2297. }
  2298. shared.applyColors();
  2299. };
  2300.  
  2301. function setHandlers() {
  2302. $("#KG-preferences .KG-dialog-close").click(() => {
  2303. hide();
  2304. });
  2305. $("#KG-preferences-save").click(() => {
  2306. preferenceManager.save(read());
  2307. hide();
  2308. });
  2309. $("#KG-preferences-reset").click(() => {
  2310. preferenceManager.reset();
  2311. page.reload();
  2312. });
  2313. }
  2314.  
  2315. function read() {
  2316. let preferences = {};
  2317. $("#KG-preferences-container input").each((i, obj) => {
  2318. let ids = obj.id.slice(14).match(/[^-]+/g);
  2319. let value;
  2320. switch (obj.type) {
  2321. case "checkbox":
  2322. value = obj.checked;
  2323. break;
  2324. default:
  2325. value = obj.value;
  2326. break;
  2327. }
  2328. if (!preferences[ids[0]]) {
  2329. preferences[ids[0]] = {};
  2330. }
  2331. preferences[ids[0]][ids[1]] = value;
  2332. });
  2333. return preferences;
  2334. }
  2335.  
  2336. },{"../config":6,"../html":24,"../util/log":57,"./page":48,"./shared":52}],52:[function(require,module,exports){
  2337. "use strict";
  2338. // src\js\ui\shared.js
  2339. const config = require("../config");
  2340.  
  2341. exports.applyColors = () => {
  2342. let site = config.sites.current();
  2343. $(".KG-episodelist-button, .KG-button")
  2344. .css({ "color": site.buttonTextColor, "background-color": site.buttonColor });
  2345. $(".KG-preferences-header")
  2346. .css({ "color": $(".bigChar").css("color") });
  2347. };
  2348.  
  2349. },{"../config":6}],53:[function(require,module,exports){
  2350. "use strict";
  2351. // src\js\ui\widget.js
  2352. const shared = require("./shared"),
  2353. html = require("../html"),
  2354. config = require("../config"),
  2355. util = require("../util"),
  2356. log = util.log,
  2357. page = require("./page"),
  2358. start = require("../start"),
  2359. preferencesUI = require("./preferences");
  2360.  
  2361. exports.show = () => {
  2362. inject();
  2363. load();
  2364. setServer(config.preferenceManager.getPreferredServer(page.location.hostname));
  2365. let noCaptchaServer = config.sites.current().noCaptchaServer;
  2366. if (noCaptchaServer != null) {
  2367. markAvailableServers(util.last(page.episodeList()), noCaptchaServer);
  2368. }
  2369. };
  2370.  
  2371. function inject() {
  2372. $(`#rightside .rightBox:eq(0)`).after(html.widget);
  2373. config.sites.current().applyPatch("widget");
  2374. }
  2375.  
  2376. function load() {
  2377. let epCount = page.episodeCount();
  2378.  
  2379. $("#KG-input-to").val(epCount)
  2380. .attr("max", epCount);
  2381. $("#KG-input-from").attr("max", epCount);
  2382. for (let server of config.sites.current().servers) {
  2383. $(`<option value="${server.identifier}">${server.name}</>`)
  2384. .appendTo("#KG-widget-server");
  2385. }
  2386. setHandlers();
  2387. shared.applyColors();
  2388. }
  2389.  
  2390. function setHandlers() {
  2391. $("#KG-input-from, #KG-input-to").on("keydown", (e) => {
  2392. if (e.keyCode == 13) {
  2393. $("#KG-input-start").click();
  2394. }
  2395. });
  2396. $("#KG-widget-server").change(() => {
  2397. config.preferenceManager.setPreferredServer(page.location.hostname, getServer());
  2398. });
  2399. $(".KG-preferences-button").click(() => {
  2400. preferencesUI.show();
  2401. });
  2402. $("#KG-input-start").click(() => {
  2403. start(getStartEpisode(), getEndEpisode(), getServer());
  2404. });
  2405. }
  2406.  
  2407. async function markAvailableServers(url, server) {
  2408. let servers = [];
  2409. let html = await $.get(`${url}&s=${server}`);
  2410. $(html).find("#selectServer").children().each((i, obj) => {
  2411. servers.push(obj.value.match(/s=\w+/g)[0].slice(2, Infinity));
  2412. });
  2413. if (servers.length == 0) {
  2414. log.warn("no servers found");
  2415. }
  2416.  
  2417. $("#KG-widget-server option").each((i, obj) => {
  2418. if (servers.indexOf(obj.value) < 0) {
  2419. $(obj).css("color", "#888");
  2420. }
  2421. });
  2422. }
  2423.  
  2424. let setServer = (server) =>
  2425. $("#KG-widget-server").val(server);
  2426.  
  2427. let getServer = exports.getServer = () =>
  2428. $("#KG-widget-server").val();
  2429.  
  2430. let getStartEpisode = () =>
  2431. $('#KG-input-from').val() - 1;
  2432.  
  2433. let getEndEpisode = () =>
  2434. $('#KG-input-to').val() - 1;
  2435.  
  2436. },{"../config":6,"../html":24,"../start":40,"../util":55,"./page":48,"./preferences":51,"./shared":52}],54:[function(require,module,exports){
  2437. "use strict";
  2438. // src\js\util\ajax.js
  2439.  
  2440. function request(method, url, { data, headers } = {}) {
  2441. return new Promise((resolve, reject) => {
  2442. GM_xmlhttpRequest({
  2443. method,
  2444. url,
  2445. data,
  2446. headers,
  2447. onload: resolve,
  2448. onerror: reject,
  2449. });
  2450. });
  2451. }
  2452.  
  2453. exports.get = (url, headers) => {
  2454. return request("GET", url, { headers });
  2455. };
  2456.  
  2457. exports.post = (url, data, headers) => {
  2458. return request("POST", url, { data, headers });
  2459. };
  2460.  
  2461. exports.head = (url, headers) => {
  2462. return request("HEAD", url, { headers });
  2463. };
  2464.  
  2465. },{}],55:[function(require,module,exports){
  2466. "use strict";
  2467. // src\js\util\index.js
  2468. exports.log = require("./log");
  2469. exports.ajax = require("./ajax");
  2470. exports.kissCrypto = require("./kissCrypto");
  2471.  
  2472. exports.for = (array, func, { min = 0, max = array.length - 1 } = {}) => {
  2473. for (let i = min; i <= max; i++) {
  2474. func(i, array[i]);
  2475. }
  2476. };
  2477.  
  2478. exports.makeBatSafe = (str) => {
  2479. return str.replace(/[%^&<>|:\\/?*"]/g, "_");
  2480. };
  2481.  
  2482. let wait = exports.wait = (time) =>
  2483. new Promise((resolve) => {
  2484. setTimeout(resolve, time);
  2485. });
  2486.  
  2487. exports.defer = async (callback = () => {}) => {
  2488. await wait(0);
  2489. callback();
  2490. };
  2491.  
  2492. exports.clone = (obj) =>
  2493. $.extend(true, {}, obj);
  2494.  
  2495. exports.clear = (obj) =>
  2496. Object.keys(obj).forEach(function(key) { delete obj[key]; });
  2497.  
  2498. exports.merge = (obj1, obj2) =>
  2499. $.extend(true, obj1, obj2);
  2500.  
  2501. exports.last = (arr) =>
  2502. arr[arr.length - 1];
  2503.  
  2504. exports.urlEncode = (obj) => {
  2505. let str = "";
  2506. for (let i in obj) {
  2507. str += `${encodeURIComponent(i)}=${encodeURIComponent(obj[i])}&`;
  2508. }
  2509. return str.slice(0, -1);
  2510. };
  2511.  
  2512. },{"./ajax":54,"./kissCrypto":56,"./log":57}],56:[function(require,module,exports){
  2513. "use strict";
  2514. // src\js\util\kissCrypto.js
  2515. const log = require("./log");
  2516.  
  2517. let scriptsLoaded = false;
  2518.  
  2519. function loadScript(name) {
  2520. $(`<script src="${location.origin}/Scripts/${name}.js" />`)
  2521. .appendTo("head");
  2522. }
  2523.  
  2524. function loadScripts() {
  2525. if (!scriptsLoaded) {
  2526. loadScript("css");
  2527. loadScript("vr");
  2528. log.log("loading scripts");
  2529. scriptsLoaded = true;
  2530. }
  2531. }
  2532.  
  2533. exports.decrypt = async (encrypted) => {
  2534. loadScripts();
  2535. return unsafeWindow.ovelWrap(encrypted);
  2536. };
  2537.  
  2538. },{"./log":57}],57:[function(require,module,exports){
  2539. "use strict";
  2540. // src\js\util\log.js
  2541. const { Logger } = require("kgrabber-types");
  2542.  
  2543. module.exports = new Logger("KGrabber", {
  2544. color: "#eee",
  2545. backgroundColor: "#456304",
  2546. });
  2547.  
  2548. },{"kgrabber-types":37}],58:[function(require,module,exports){
  2549. // shim for using process in browser
  2550. var process = module.exports = {};
  2551.  
  2552. // cached from whatever global is present so that test runners that stub it
  2553. // don't break things. But we need to wrap it in a try catch in case it is
  2554. // wrapped in strict mode code which doesn't define any globals. It's inside a
  2555. // function because try/catches deoptimize in certain engines.
  2556.  
  2557. var cachedSetTimeout;
  2558. var cachedClearTimeout;
  2559.  
  2560. function defaultSetTimout() {
  2561. throw new Error('setTimeout has not been defined');
  2562. }
  2563. function defaultClearTimeout () {
  2564. throw new Error('clearTimeout has not been defined');
  2565. }
  2566. (function () {
  2567. try {
  2568. if (typeof setTimeout === 'function') {
  2569. cachedSetTimeout = setTimeout;
  2570. } else {
  2571. cachedSetTimeout = defaultSetTimout;
  2572. }
  2573. } catch (e) {
  2574. cachedSetTimeout = defaultSetTimout;
  2575. }
  2576. try {
  2577. if (typeof clearTimeout === 'function') {
  2578. cachedClearTimeout = clearTimeout;
  2579. } else {
  2580. cachedClearTimeout = defaultClearTimeout;
  2581. }
  2582. } catch (e) {
  2583. cachedClearTimeout = defaultClearTimeout;
  2584. }
  2585. } ())
  2586. function runTimeout(fun) {
  2587. if (cachedSetTimeout === setTimeout) {
  2588. //normal enviroments in sane situations
  2589. return setTimeout(fun, 0);
  2590. }
  2591. // if setTimeout wasn't available but was latter defined
  2592. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  2593. cachedSetTimeout = setTimeout;
  2594. return setTimeout(fun, 0);
  2595. }
  2596. try {
  2597. // when when somebody has screwed with setTimeout but no I.E. maddness
  2598. return cachedSetTimeout(fun, 0);
  2599. } catch(e){
  2600. try {
  2601. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  2602. return cachedSetTimeout.call(null, fun, 0);
  2603. } catch(e){
  2604. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  2605. return cachedSetTimeout.call(this, fun, 0);
  2606. }
  2607. }
  2608.  
  2609.  
  2610. }
  2611. function runClearTimeout(marker) {
  2612. if (cachedClearTimeout === clearTimeout) {
  2613. //normal enviroments in sane situations
  2614. return clearTimeout(marker);
  2615. }
  2616. // if clearTimeout wasn't available but was latter defined
  2617. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  2618. cachedClearTimeout = clearTimeout;
  2619. return clearTimeout(marker);
  2620. }
  2621. try {
  2622. // when when somebody has screwed with setTimeout but no I.E. maddness
  2623. return cachedClearTimeout(marker);
  2624. } catch (e){
  2625. try {
  2626. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  2627. return cachedClearTimeout.call(null, marker);
  2628. } catch (e){
  2629. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  2630. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  2631. return cachedClearTimeout.call(this, marker);
  2632. }
  2633. }
  2634.  
  2635.  
  2636.  
  2637. }
  2638. var queue = [];
  2639. var draining = false;
  2640. var currentQueue;
  2641. var queueIndex = -1;
  2642.  
  2643. function cleanUpNextTick() {
  2644. if (!draining || !currentQueue) {
  2645. return;
  2646. }
  2647. draining = false;
  2648. if (currentQueue.length) {
  2649. queue = currentQueue.concat(queue);
  2650. } else {
  2651. queueIndex = -1;
  2652. }
  2653. if (queue.length) {
  2654. drainQueue();
  2655. }
  2656. }
  2657.  
  2658. function drainQueue() {
  2659. if (draining) {
  2660. return;
  2661. }
  2662. var timeout = runTimeout(cleanUpNextTick);
  2663. draining = true;
  2664.  
  2665. var len = queue.length;
  2666. while(len) {
  2667. currentQueue = queue;
  2668. queue = [];
  2669. while (++queueIndex < len) {
  2670. if (currentQueue) {
  2671. currentQueue[queueIndex].run();
  2672. }
  2673. }
  2674. queueIndex = -1;
  2675. len = queue.length;
  2676. }
  2677. currentQueue = null;
  2678. draining = false;
  2679. runClearTimeout(timeout);
  2680. }
  2681.  
  2682. process.nextTick = function (fun) {
  2683. var args = new Array(arguments.length - 1);
  2684. if (arguments.length > 1) {
  2685. for (var i = 1; i < arguments.length; i++) {
  2686. args[i - 1] = arguments[i];
  2687. }
  2688. }
  2689. queue.push(new Item(fun, args));
  2690. if (queue.length === 1 && !draining) {
  2691. runTimeout(drainQueue);
  2692. }
  2693. };
  2694.  
  2695. // v8 likes predictible objects
  2696. function Item(fun, array) {
  2697. this.fun = fun;
  2698. this.array = array;
  2699. }
  2700. Item.prototype.run = function () {
  2701. this.fun.apply(null, this.array);
  2702. };
  2703. process.title = 'browser';
  2704. process.browser = true;
  2705. process.env = {};
  2706. process.argv = [];
  2707. process.version = ''; // empty string to avoid regexp issues
  2708. process.versions = {};
  2709.  
  2710. function noop() {}
  2711.  
  2712. process.on = noop;
  2713. process.addListener = noop;
  2714. process.once = noop;
  2715. process.off = noop;
  2716. process.removeListener = noop;
  2717. process.removeAllListeners = noop;
  2718. process.emit = noop;
  2719. process.prependListener = noop;
  2720. process.prependOnceListener = noop;
  2721.  
  2722. process.listeners = function (name) { return [] }
  2723.  
  2724. process.binding = function (name) {
  2725. throw new Error('process.binding is not supported');
  2726. };
  2727.  
  2728. process.cwd = function () { return '/' };
  2729. process.chdir = function (dir) {
  2730. throw new Error('process.chdir is not supported');
  2731. };
  2732. process.umask = function() { return 0; };
  2733.  
  2734. },{}],59:[function(require,module,exports){
  2735. const ANY = Symbol('SemVer ANY')
  2736. // hoisted class for cyclic dependency
  2737. class Comparator {
  2738. static get ANY () {
  2739. return ANY
  2740. }
  2741. constructor (comp, options) {
  2742. if (!options || typeof options !== 'object') {
  2743. options = {
  2744. loose: !!options,
  2745. includePrerelease: false
  2746. }
  2747. }
  2748.  
  2749. if (comp instanceof Comparator) {
  2750. if (comp.loose === !!options.loose) {
  2751. return comp
  2752. } else {
  2753. comp = comp.value
  2754. }
  2755. }
  2756.  
  2757. debug('comparator', comp, options)
  2758. this.options = options
  2759. this.loose = !!options.loose
  2760. this.parse(comp)
  2761.  
  2762. if (this.semver === ANY) {
  2763. this.value = ''
  2764. } else {
  2765. this.value = this.operator + this.semver.version
  2766. }
  2767.  
  2768. debug('comp', this)
  2769. }
  2770.  
  2771. parse (comp) {
  2772. const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
  2773. const m = comp.match(r)
  2774.  
  2775. if (!m) {
  2776. throw new TypeError(`Invalid comparator: ${comp}`)
  2777. }
  2778.  
  2779. this.operator = m[1] !== undefined ? m[1] : ''
  2780. if (this.operator === '=') {
  2781. this.operator = ''
  2782. }
  2783.  
  2784. // if it literally is just '>' or '' then allow anything.
  2785. if (!m[2]) {
  2786. this.semver = ANY
  2787. } else {
  2788. this.semver = new SemVer(m[2], this.options.loose)
  2789. }
  2790. }
  2791.  
  2792. toString () {
  2793. return this.value
  2794. }
  2795.  
  2796. test (version) {
  2797. debug('Comparator.test', version, this.options.loose)
  2798.  
  2799. if (this.semver === ANY || version === ANY) {
  2800. return true
  2801. }
  2802.  
  2803. if (typeof version === 'string') {
  2804. try {
  2805. version = new SemVer(version, this.options)
  2806. } catch (er) {
  2807. return false
  2808. }
  2809. }
  2810.  
  2811. return cmp(version, this.operator, this.semver, this.options)
  2812. }
  2813.  
  2814. intersects (comp, options) {
  2815. if (!(comp instanceof Comparator)) {
  2816. throw new TypeError('a Comparator is required')
  2817. }
  2818.  
  2819. if (!options || typeof options !== 'object') {
  2820. options = {
  2821. loose: !!options,
  2822. includePrerelease: false
  2823. }
  2824. }
  2825.  
  2826. if (this.operator === '') {
  2827. if (this.value === '') {
  2828. return true
  2829. }
  2830. return new Range(comp.value, options).test(this.value)
  2831. } else if (comp.operator === '') {
  2832. if (comp.value === '') {
  2833. return true
  2834. }
  2835. return new Range(this.value, options).test(comp.semver)
  2836. }
  2837.  
  2838. const sameDirectionIncreasing =
  2839. (this.operator === '>=' || this.operator === '>') &&
  2840. (comp.operator === '>=' || comp.operator === '>')
  2841. const sameDirectionDecreasing =
  2842. (this.operator === '<=' || this.operator === '<') &&
  2843. (comp.operator === '<=' || comp.operator === '<')
  2844. const sameSemVer = this.semver.version === comp.semver.version
  2845. const differentDirectionsInclusive =
  2846. (this.operator === '>=' || this.operator === '<=') &&
  2847. (comp.operator === '>=' || comp.operator === '<=')
  2848. const oppositeDirectionsLessThan =
  2849. cmp(this.semver, '<', comp.semver, options) &&
  2850. (this.operator === '>=' || this.operator === '>') &&
  2851. (comp.operator === '<=' || comp.operator === '<')
  2852. const oppositeDirectionsGreaterThan =
  2853. cmp(this.semver, '>', comp.semver, options) &&
  2854. (this.operator === '<=' || this.operator === '<') &&
  2855. (comp.operator === '>=' || comp.operator === '>')
  2856.  
  2857. return (
  2858. sameDirectionIncreasing ||
  2859. sameDirectionDecreasing ||
  2860. (sameSemVer && differentDirectionsInclusive) ||
  2861. oppositeDirectionsLessThan ||
  2862. oppositeDirectionsGreaterThan
  2863. )
  2864. }
  2865. }
  2866.  
  2867. module.exports = Comparator
  2868.  
  2869. const {re, t} = require('../internal/re')
  2870. const cmp = require('../functions/cmp')
  2871. const debug = require('../internal/debug')
  2872. const SemVer = require('./semver')
  2873. const Range = require('./range')
  2874.  
  2875. },{"../functions/cmp":62,"../internal/debug":72,"../internal/re":74,"./range":60,"./semver":61}],60:[function(require,module,exports){
  2876. // hoisted class for cyclic dependency
  2877. class Range {
  2878. constructor (range, options) {
  2879. if (!options || typeof options !== 'object') {
  2880. options = {
  2881. loose: !!options,
  2882. includePrerelease: false
  2883. }
  2884. }
  2885.  
  2886. if (range instanceof Range) {
  2887. if (
  2888. range.loose === !!options.loose &&
  2889. range.includePrerelease === !!options.includePrerelease
  2890. ) {
  2891. return range
  2892. } else {
  2893. return new Range(range.raw, options)
  2894. }
  2895. }
  2896.  
  2897. if (range instanceof Comparator) {
  2898. // just put it in the set and return
  2899. this.raw = range.value
  2900. this.set = [[range]]
  2901. this.format()
  2902. return this
  2903. }
  2904.  
  2905. this.options = options
  2906. this.loose = !!options.loose
  2907. this.includePrerelease = !!options.includePrerelease
  2908.  
  2909. // First, split based on boolean or ||
  2910. this.raw = range
  2911. this.set = range
  2912. .split(/\s*\|\|\s*/)
  2913. // map the range to a 2d array of comparators
  2914. .map(range => this.parseRange(range.trim()))
  2915. // throw out any comparator lists that are empty
  2916. // this generally means that it was not a valid range, which is allowed
  2917. // in loose mode, but will still throw if the WHOLE range is invalid.
  2918. .filter(c => c.length)
  2919.  
  2920. if (!this.set.length) {
  2921. throw new TypeError(`Invalid SemVer Range: ${range}`)
  2922. }
  2923.  
  2924. this.format()
  2925. }
  2926.  
  2927. format () {
  2928. this.range = this.set
  2929. .map((comps) => {
  2930. return comps.join(' ').trim()
  2931. })
  2932. .join('||')
  2933. .trim()
  2934. return this.range
  2935. }
  2936.  
  2937. toString () {
  2938. return this.range
  2939. }
  2940.  
  2941. parseRange (range) {
  2942. const loose = this.options.loose
  2943. range = range.trim()
  2944. // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
  2945. const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]
  2946. range = range.replace(hr, hyphenReplace(this.options.includePrerelease))
  2947. debug('hyphen replace', range)
  2948. // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
  2949. range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)
  2950. debug('comparator trim', range, re[t.COMPARATORTRIM])
  2951.  
  2952. // `~ 1.2.3` => `~1.2.3`
  2953. range = range.replace(re[t.TILDETRIM], tildeTrimReplace)
  2954.  
  2955. // `^ 1.2.3` => `^1.2.3`
  2956. range = range.replace(re[t.CARETTRIM], caretTrimReplace)
  2957.  
  2958. // normalize spaces
  2959. range = range.split(/\s+/).join(' ')
  2960.  
  2961. // At this point, the range is completely trimmed and
  2962. // ready to be split into comparators.
  2963.  
  2964. const compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
  2965. return range
  2966. .split(' ')
  2967. .map(comp => parseComparator(comp, this.options))
  2968. .join(' ')
  2969. .split(/\s+/)
  2970. .map(comp => replaceGTE0(comp, this.options))
  2971. // in loose mode, throw out any that are not valid comparators
  2972. .filter(this.options.loose ? comp => !!comp.match(compRe) : () => true)
  2973. .map(comp => new Comparator(comp, this.options))
  2974. }
  2975.  
  2976. intersects (range, options) {
  2977. if (!(range instanceof Range)) {
  2978. throw new TypeError('a Range is required')
  2979. }
  2980.  
  2981. return this.set.some((thisComparators) => {
  2982. return (
  2983. isSatisfiable(thisComparators, options) &&
  2984. range.set.some((rangeComparators) => {
  2985. return (
  2986. isSatisfiable(rangeComparators, options) &&
  2987. thisComparators.every((thisComparator) => {
  2988. return rangeComparators.every((rangeComparator) => {
  2989. return thisComparator.intersects(rangeComparator, options)
  2990. })
  2991. })
  2992. )
  2993. })
  2994. )
  2995. })
  2996. }
  2997.  
  2998. // if ANY of the sets match ALL of its comparators, then pass
  2999. test (version) {
  3000. if (!version) {
  3001. return false
  3002. }
  3003.  
  3004. if (typeof version === 'string') {
  3005. try {
  3006. version = new SemVer(version, this.options)
  3007. } catch (er) {
  3008. return false
  3009. }
  3010. }
  3011.  
  3012. for (let i = 0; i < this.set.length; i++) {
  3013. if (testSet(this.set[i], version, this.options)) {
  3014. return true
  3015. }
  3016. }
  3017. return false
  3018. }
  3019. }
  3020. module.exports = Range
  3021.  
  3022. const Comparator = require('./comparator')
  3023. const debug = require('../internal/debug')
  3024. const SemVer = require('./semver')
  3025. const {
  3026. re,
  3027. t,
  3028. comparatorTrimReplace,
  3029. tildeTrimReplace,
  3030. caretTrimReplace
  3031. } = require('../internal/re')
  3032.  
  3033. // take a set of comparators and determine whether there
  3034. // exists a version which can satisfy it
  3035. const isSatisfiable = (comparators, options) => {
  3036. let result = true
  3037. const remainingComparators = comparators.slice()
  3038. let testComparator = remainingComparators.pop()
  3039.  
  3040. while (result && remainingComparators.length) {
  3041. result = remainingComparators.every((otherComparator) => {
  3042. return testComparator.intersects(otherComparator, options)
  3043. })
  3044.  
  3045. testComparator = remainingComparators.pop()
  3046. }
  3047.  
  3048. return result
  3049. }
  3050.  
  3051. // comprised of xranges, tildes, stars, and gtlt's at this point.
  3052. // already replaced the hyphen ranges
  3053. // turn into a set of JUST comparators.
  3054. const parseComparator = (comp, options) => {
  3055. debug('comp', comp, options)
  3056. comp = replaceCarets(comp, options)
  3057. debug('caret', comp)
  3058. comp = replaceTildes(comp, options)
  3059. debug('tildes', comp)
  3060. comp = replaceXRanges(comp, options)
  3061. debug('xrange', comp)
  3062. comp = replaceStars(comp, options)
  3063. debug('stars', comp)
  3064. return comp
  3065. }
  3066.  
  3067. const isX = id => !id || id.toLowerCase() === 'x' || id === '*'
  3068.  
  3069. // ~, ~> --> * (any, kinda silly)
  3070. // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
  3071. // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
  3072. // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
  3073. // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
  3074. // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
  3075. const replaceTildes = (comp, options) =>
  3076. comp.trim().split(/\s+/).map((comp) => {
  3077. return replaceTilde(comp, options)
  3078. }).join(' ')
  3079.  
  3080. const replaceTilde = (comp, options) => {
  3081. const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]
  3082. return comp.replace(r, (_, M, m, p, pr) => {
  3083. debug('tilde', comp, _, M, m, p, pr)
  3084. let ret
  3085.  
  3086. if (isX(M)) {
  3087. ret = ''
  3088. } else if (isX(m)) {
  3089. ret = `>=${M}.0.0 <${+M + 1}.0.0-0`
  3090. } else if (isX(p)) {
  3091. // ~1.2 == >=1.2.0 <1.3.0-0
  3092. ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`
  3093. } else if (pr) {
  3094. debug('replaceTilde pr', pr)
  3095. ret = `>=${M}.${m}.${p}-${pr
  3096. } <${M}.${+m + 1}.0-0`
  3097. } else {
  3098. // ~1.2.3 == >=1.2.3 <1.3.0-0
  3099. ret = `>=${M}.${m}.${p
  3100. } <${M}.${+m + 1}.0-0`
  3101. }
  3102.  
  3103. debug('tilde return', ret)
  3104. return ret
  3105. })
  3106. }
  3107.  
  3108. // ^ --> * (any, kinda silly)
  3109. // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
  3110. // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
  3111. // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
  3112. // ^1.2.3 --> >=1.2.3 <2.0.0-0
  3113. // ^1.2.0 --> >=1.2.0 <2.0.0-0
  3114. const replaceCarets = (comp, options) =>
  3115. comp.trim().split(/\s+/).map((comp) => {
  3116. return replaceCaret(comp, options)
  3117. }).join(' ')
  3118.  
  3119. const replaceCaret = (comp, options) => {
  3120. debug('caret', comp, options)
  3121. const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]
  3122. const z = options.includePrerelease ? '-0' : ''
  3123. return comp.replace(r, (_, M, m, p, pr) => {
  3124. debug('caret', comp, _, M, m, p, pr)
  3125. let ret
  3126.  
  3127. if (isX(M)) {
  3128. ret = ''
  3129. } else if (isX(m)) {
  3130. ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`
  3131. } else if (isX(p)) {
  3132. if (M === '0') {
  3133. ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`
  3134. } else {
  3135. ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`
  3136. }
  3137. } else if (pr) {
  3138. debug('replaceCaret pr', pr)
  3139. if (M === '0') {
  3140. if (m === '0') {
  3141. ret = `>=${M}.${m}.${p}-${pr
  3142. } <${M}.${m}.${+p + 1}-0`
  3143. } else {
  3144. ret = `>=${M}.${m}.${p}-${pr
  3145. } <${M}.${+m + 1}.0-0`
  3146. }
  3147. } else {
  3148. ret = `>=${M}.${m}.${p}-${pr
  3149. } <${+M + 1}.0.0-0`
  3150. }
  3151. } else {
  3152. debug('no pr')
  3153. if (M === '0') {
  3154. if (m === '0') {
  3155. ret = `>=${M}.${m}.${p
  3156. }${z} <${M}.${m}.${+p + 1}-0`
  3157. } else {
  3158. ret = `>=${M}.${m}.${p
  3159. }${z} <${M}.${+m + 1}.0-0`
  3160. }
  3161. } else {
  3162. ret = `>=${M}.${m}.${p
  3163. } <${+M + 1}.0.0-0`
  3164. }
  3165. }
  3166.  
  3167. debug('caret return', ret)
  3168. return ret
  3169. })
  3170. }
  3171.  
  3172. const replaceXRanges = (comp, options) => {
  3173. debug('replaceXRanges', comp, options)
  3174. return comp.split(/\s+/).map((comp) => {
  3175. return replaceXRange(comp, options)
  3176. }).join(' ')
  3177. }
  3178.  
  3179. const replaceXRange = (comp, options) => {
  3180. comp = comp.trim()
  3181. const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]
  3182. return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
  3183. debug('xRange', comp, ret, gtlt, M, m, p, pr)
  3184. const xM = isX(M)
  3185. const xm = xM || isX(m)
  3186. const xp = xm || isX(p)
  3187. const anyX = xp
  3188.  
  3189. if (gtlt === '=' && anyX) {
  3190. gtlt = ''
  3191. }
  3192.  
  3193. // if we're including prereleases in the match, then we need
  3194. // to fix this to -0, the lowest possible prerelease value
  3195. pr = options.includePrerelease ? '-0' : ''
  3196.  
  3197. if (xM) {
  3198. if (gtlt === '>' || gtlt === '<') {
  3199. // nothing is allowed
  3200. ret = '<0.0.0-0'
  3201. } else {
  3202. // nothing is forbidden
  3203. ret = '*'
  3204. }
  3205. } else if (gtlt && anyX) {
  3206. // we know patch is an x, because we have any x at all.
  3207. // replace X with 0
  3208. if (xm) {
  3209. m = 0
  3210. }
  3211. p = 0
  3212.  
  3213. if (gtlt === '>') {
  3214. // >1 => >=2.0.0
  3215. // >1.2 => >=1.3.0
  3216. gtlt = '>='
  3217. if (xm) {
  3218. M = +M + 1
  3219. m = 0
  3220. p = 0
  3221. } else {
  3222. m = +m + 1
  3223. p = 0
  3224. }
  3225. } else if (gtlt === '<=') {
  3226. // <=0.7.x is actually <0.8.0, since any 0.7.x should
  3227. // pass. Similarly, <=7.x is actually <8.0.0, etc.
  3228. gtlt = '<'
  3229. if (xm) {
  3230. M = +M + 1
  3231. } else {
  3232. m = +m + 1
  3233. }
  3234. }
  3235.  
  3236. if (gtlt === '<')
  3237. pr = '-0'
  3238.  
  3239. ret = `${gtlt + M}.${m}.${p}${pr}`
  3240. } else if (xm) {
  3241. ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`
  3242. } else if (xp) {
  3243. ret = `>=${M}.${m}.0${pr
  3244. } <${M}.${+m + 1}.0-0`
  3245. }
  3246.  
  3247. debug('xRange return', ret)
  3248.  
  3249. return ret
  3250. })
  3251. }
  3252.  
  3253. // Because * is AND-ed with everything else in the comparator,
  3254. // and '' means "any version", just remove the *s entirely.
  3255. const replaceStars = (comp, options) => {
  3256. debug('replaceStars', comp, options)
  3257. // Looseness is ignored here. star is always as loose as it gets!
  3258. return comp.trim().replace(re[t.STAR], '')
  3259. }
  3260.  
  3261. const replaceGTE0 = (comp, options) => {
  3262. debug('replaceGTE0', comp, options)
  3263. return comp.trim()
  3264. .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')
  3265. }
  3266.  
  3267. // This function is passed to string.replace(re[t.HYPHENRANGE])
  3268. // M, m, patch, prerelease, build
  3269. // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
  3270. // 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
  3271. // 1.2 - 3.4 => >=1.2.0 <3.5.0-0
  3272. const hyphenReplace = incPr => ($0,
  3273. from, fM, fm, fp, fpr, fb,
  3274. to, tM, tm, tp, tpr, tb) => {
  3275. if (isX(fM)) {
  3276. from = ''
  3277. } else if (isX(fm)) {
  3278. from = `>=${fM}.0.0${incPr ? '-0' : ''}`
  3279. } else if (isX(fp)) {
  3280. from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`
  3281. } else if (fpr) {
  3282. from = `>=${from}`
  3283. } else {
  3284. from = `>=${from}${incPr ? '-0' : ''}`
  3285. }
  3286.  
  3287. if (isX(tM)) {
  3288. to = ''
  3289. } else if (isX(tm)) {
  3290. to = `<${+tM + 1}.0.0-0`
  3291. } else if (isX(tp)) {
  3292. to = `<${tM}.${+tm + 1}.0-0`
  3293. } else if (tpr) {
  3294. to = `<=${tM}.${tm}.${tp}-${tpr}`
  3295. } else if (incPr) {
  3296. to = `<${tM}.${tm}.${+tp + 1}-0`
  3297. } else {
  3298. to = `<=${to}`
  3299. }
  3300.  
  3301. return (`${from} ${to}`).trim()
  3302. }
  3303.  
  3304. const testSet = (set, version, options) => {
  3305. for (let i = 0; i < set.length; i++) {
  3306. if (!set[i].test(version)) {
  3307. return false
  3308. }
  3309. }
  3310.  
  3311. if (version.prerelease.length && !options.includePrerelease) {
  3312. // Find the set of versions that are allowed to have prereleases
  3313. // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
  3314. // That should allow `1.2.3-pr.2` to pass.
  3315. // However, `1.2.4-alpha.notready` should NOT be allowed,
  3316. // even though it's within the range set by the comparators.
  3317. for (let i = 0; i < set.length; i++) {
  3318. debug(set[i].semver)
  3319. if (set[i].semver === Comparator.ANY) {
  3320. continue
  3321. }
  3322.  
  3323. if (set[i].semver.prerelease.length > 0) {
  3324. const allowed = set[i].semver
  3325. if (allowed.major === version.major &&
  3326. allowed.minor === version.minor &&
  3327. allowed.patch === version.patch) {
  3328. return true
  3329. }
  3330. }
  3331. }
  3332.  
  3333. // Version has a -pre, but it's not one of the ones we like.
  3334. return false
  3335. }
  3336.  
  3337. return true
  3338. }
  3339.  
  3340. },{"../internal/debug":72,"../internal/re":74,"./comparator":59,"./semver":61}],61:[function(require,module,exports){
  3341. const debug = require('../internal/debug')
  3342. const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants')
  3343. const { re, t } = require('../internal/re')
  3344.  
  3345. const { compareIdentifiers } = require('../internal/identifiers')
  3346. class SemVer {
  3347. constructor (version, options) {
  3348. if (!options || typeof options !== 'object') {
  3349. options = {
  3350. loose: !!options,
  3351. includePrerelease: false
  3352. }
  3353. }
  3354. if (version instanceof SemVer) {
  3355. if (version.loose === !!options.loose &&
  3356. version.includePrerelease === !!options.includePrerelease) {
  3357. return version
  3358. } else {
  3359. version = version.version
  3360. }
  3361. } else if (typeof version !== 'string') {
  3362. throw new TypeError(`Invalid Version: ${version}`)
  3363. }
  3364.  
  3365. if (version.length > MAX_LENGTH) {
  3366. throw new TypeError(
  3367. `version is longer than ${MAX_LENGTH} characters`
  3368. )
  3369. }
  3370.  
  3371. debug('SemVer', version, options)
  3372. this.options = options
  3373. this.loose = !!options.loose
  3374. // this isn't actually relevant for versions, but keep it so that we
  3375. // don't run into trouble passing this.options around.
  3376. this.includePrerelease = !!options.includePrerelease
  3377.  
  3378. const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL])
  3379.  
  3380. if (!m) {
  3381. throw new TypeError(`Invalid Version: ${version}`)
  3382. }
  3383.  
  3384. this.raw = version
  3385.  
  3386. // these are actually numbers
  3387. this.major = +m[1]
  3388. this.minor = +m[2]
  3389. this.patch = +m[3]
  3390.  
  3391. if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
  3392. throw new TypeError('Invalid major version')
  3393. }
  3394.  
  3395. if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
  3396. throw new TypeError('Invalid minor version')
  3397. }
  3398.  
  3399. if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
  3400. throw new TypeError('Invalid patch version')
  3401. }
  3402.  
  3403. // numberify any prerelease numeric ids
  3404. if (!m[4]) {
  3405. this.prerelease = []
  3406. } else {
  3407. this.prerelease = m[4].split('.').map((id) => {
  3408. if (/^[0-9]+$/.test(id)) {
  3409. const num = +id
  3410. if (num >= 0 && num < MAX_SAFE_INTEGER) {
  3411. return num
  3412. }
  3413. }
  3414. return id
  3415. })
  3416. }
  3417.  
  3418. this.build = m[5] ? m[5].split('.') : []
  3419. this.format()
  3420. }
  3421.  
  3422. format () {
  3423. this.version = `${this.major}.${this.minor}.${this.patch}`
  3424. if (this.prerelease.length) {
  3425. this.version += `-${this.prerelease.join('.')}`
  3426. }
  3427. return this.version
  3428. }
  3429.  
  3430. toString () {
  3431. return this.version
  3432. }
  3433.  
  3434. compare (other) {
  3435. debug('SemVer.compare', this.version, this.options, other)
  3436. if (!(other instanceof SemVer)) {
  3437. if (typeof other === 'string' && other === this.version) {
  3438. return 0
  3439. }
  3440. other = new SemVer(other, this.options)
  3441. }
  3442.  
  3443. if (other.version === this.version) {
  3444. return 0
  3445. }
  3446.  
  3447. return this.compareMain(other) || this.comparePre(other)
  3448. }
  3449.  
  3450. compareMain (other) {
  3451. if (!(other instanceof SemVer)) {
  3452. other = new SemVer(other, this.options)
  3453. }
  3454.  
  3455. return (
  3456. compareIdentifiers(this.major, other.major) ||
  3457. compareIdentifiers(this.minor, other.minor) ||
  3458. compareIdentifiers(this.patch, other.patch)
  3459. )
  3460. }
  3461.  
  3462. comparePre (other) {
  3463. if (!(other instanceof SemVer)) {
  3464. other = new SemVer(other, this.options)
  3465. }
  3466.  
  3467. // NOT having a prerelease is > having one
  3468. if (this.prerelease.length && !other.prerelease.length) {
  3469. return -1
  3470. } else if (!this.prerelease.length && other.prerelease.length) {
  3471. return 1
  3472. } else if (!this.prerelease.length && !other.prerelease.length) {
  3473. return 0
  3474. }
  3475.  
  3476. let i = 0
  3477. do {
  3478. const a = this.prerelease[i]
  3479. const b = other.prerelease[i]
  3480. debug('prerelease compare', i, a, b)
  3481. if (a === undefined && b === undefined) {
  3482. return 0
  3483. } else if (b === undefined) {
  3484. return 1
  3485. } else if (a === undefined) {
  3486. return -1
  3487. } else if (a === b) {
  3488. continue
  3489. } else {
  3490. return compareIdentifiers(a, b)
  3491. }
  3492. } while (++i)
  3493. }
  3494.  
  3495. compareBuild (other) {
  3496. if (!(other instanceof SemVer)) {
  3497. other = new SemVer(other, this.options)
  3498. }
  3499.  
  3500. let i = 0
  3501. do {
  3502. const a = this.build[i]
  3503. const b = other.build[i]
  3504. debug('prerelease compare', i, a, b)
  3505. if (a === undefined && b === undefined) {
  3506. return 0
  3507. } else if (b === undefined) {
  3508. return 1
  3509. } else if (a === undefined) {
  3510. return -1
  3511. } else if (a === b) {
  3512. continue
  3513. } else {
  3514. return compareIdentifiers(a, b)
  3515. }
  3516. } while (++i)
  3517. }
  3518.  
  3519. // preminor will bump the version up to the next minor release, and immediately
  3520. // down to pre-release. premajor and prepatch work the same way.
  3521. inc (release, identifier) {
  3522. switch (release) {
  3523. case 'premajor':
  3524. this.prerelease.length = 0
  3525. this.patch = 0
  3526. this.minor = 0
  3527. this.major++
  3528. this.inc('pre', identifier)
  3529. break
  3530. case 'preminor':
  3531. this.prerelease.length = 0
  3532. this.patch = 0
  3533. this.minor++
  3534. this.inc('pre', identifier)
  3535. break
  3536. case 'prepatch':
  3537. // If this is already a prerelease, it will bump to the next version
  3538. // drop any prereleases that might already exist, since they are not
  3539. // relevant at this point.
  3540. this.prerelease.length = 0
  3541. this.inc('patch', identifier)
  3542. this.inc('pre', identifier)
  3543. break
  3544. // If the input is a non-prerelease version, this acts the same as
  3545. // prepatch.
  3546. case 'prerelease':
  3547. if (this.prerelease.length === 0) {
  3548. this.inc('patch', identifier)
  3549. }
  3550. this.inc('pre', identifier)
  3551. break
  3552.  
  3553. case 'major':
  3554. // If this is a pre-major version, bump up to the same major version.
  3555. // Otherwise increment major.
  3556. // 1.0.0-5 bumps to 1.0.0
  3557. // 1.1.0 bumps to 2.0.0
  3558. if (
  3559. this.minor !== 0 ||
  3560. this.patch !== 0 ||
  3561. this.prerelease.length === 0
  3562. ) {
  3563. this.major++
  3564. }
  3565. this.minor = 0
  3566. this.patch = 0
  3567. this.prerelease = []
  3568. break
  3569. case 'minor':
  3570. // If this is a pre-minor version, bump up to the same minor version.
  3571. // Otherwise increment minor.
  3572. // 1.2.0-5 bumps to 1.2.0
  3573. // 1.2.1 bumps to 1.3.0
  3574. if (this.patch !== 0 || this.prerelease.length === 0) {
  3575. this.minor++
  3576. }
  3577. this.patch = 0
  3578. this.prerelease = []
  3579. break
  3580. case 'patch':
  3581. // If this is not a pre-release version, it will increment the patch.
  3582. // If it is a pre-release it will bump up to the same patch version.
  3583. // 1.2.0-5 patches to 1.2.0
  3584. // 1.2.0 patches to 1.2.1
  3585. if (this.prerelease.length === 0) {
  3586. this.patch++
  3587. }
  3588. this.prerelease = []
  3589. break
  3590. // This probably shouldn't be used publicly.
  3591. // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
  3592. case 'pre':
  3593. if (this.prerelease.length === 0) {
  3594. this.prerelease = [0]
  3595. } else {
  3596. let i = this.prerelease.length
  3597. while (--i >= 0) {
  3598. if (typeof this.prerelease[i] === 'number') {
  3599. this.prerelease[i]++
  3600. i = -2
  3601. }
  3602. }
  3603. if (i === -1) {
  3604. // didn't increment anything
  3605. this.prerelease.push(0)
  3606. }
  3607. }
  3608. if (identifier) {
  3609. // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
  3610. // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
  3611. if (this.prerelease[0] === identifier) {
  3612. if (isNaN(this.prerelease[1])) {
  3613. this.prerelease = [identifier, 0]
  3614. }
  3615. } else {
  3616. this.prerelease = [identifier, 0]
  3617. }
  3618. }
  3619. break
  3620.  
  3621. default:
  3622. throw new Error(`invalid increment argument: ${release}`)
  3623. }
  3624. this.format()
  3625. this.raw = this.version
  3626. return this
  3627. }
  3628. }
  3629.  
  3630. module.exports = SemVer
  3631.  
  3632. },{"../internal/constants":71,"../internal/debug":72,"../internal/identifiers":73,"../internal/re":74}],62:[function(require,module,exports){
  3633. const eq = require('./eq')
  3634. const neq = require('./neq')
  3635. const gt = require('./gt')
  3636. const gte = require('./gte')
  3637. const lt = require('./lt')
  3638. const lte = require('./lte')
  3639.  
  3640. const cmp = (a, op, b, loose) => {
  3641. switch (op) {
  3642. case '===':
  3643. if (typeof a === 'object')
  3644. a = a.version
  3645. if (typeof b === 'object')
  3646. b = b.version
  3647. return a === b
  3648.  
  3649. case '!==':
  3650. if (typeof a === 'object')
  3651. a = a.version
  3652. if (typeof b === 'object')
  3653. b = b.version
  3654. return a !== b
  3655.  
  3656. case '':
  3657. case '=':
  3658. case '==':
  3659. return eq(a, b, loose)
  3660.  
  3661. case '!=':
  3662. return neq(a, b, loose)
  3663.  
  3664. case '>':
  3665. return gt(a, b, loose)
  3666.  
  3667. case '>=':
  3668. return gte(a, b, loose)
  3669.  
  3670. case '<':
  3671. return lt(a, b, loose)
  3672.  
  3673. case '<=':
  3674. return lte(a, b, loose)
  3675.  
  3676. default:
  3677. throw new TypeError(`Invalid operator: ${op}`)
  3678. }
  3679. }
  3680. module.exports = cmp
  3681.  
  3682. },{"./eq":64,"./gt":65,"./gte":66,"./lt":67,"./lte":68,"./neq":69}],63:[function(require,module,exports){
  3683. const SemVer = require('../classes/semver')
  3684. const compare = (a, b, loose) =>
  3685. new SemVer(a, loose).compare(new SemVer(b, loose))
  3686.  
  3687. module.exports = compare
  3688.  
  3689. },{"../classes/semver":61}],64:[function(require,module,exports){
  3690. const compare = require('./compare')
  3691. const eq = (a, b, loose) => compare(a, b, loose) === 0
  3692. module.exports = eq
  3693.  
  3694. },{"./compare":63}],65:[function(require,module,exports){
  3695. const compare = require('./compare')
  3696. const gt = (a, b, loose) => compare(a, b, loose) > 0
  3697. module.exports = gt
  3698.  
  3699. },{"./compare":63}],66:[function(require,module,exports){
  3700. const compare = require('./compare')
  3701. const gte = (a, b, loose) => compare(a, b, loose) >= 0
  3702. module.exports = gte
  3703.  
  3704. },{"./compare":63}],67:[function(require,module,exports){
  3705. const compare = require('./compare')
  3706. const lt = (a, b, loose) => compare(a, b, loose) < 0
  3707. module.exports = lt
  3708.  
  3709. },{"./compare":63}],68:[function(require,module,exports){
  3710. const compare = require('./compare')
  3711. const lte = (a, b, loose) => compare(a, b, loose) <= 0
  3712. module.exports = lte
  3713.  
  3714. },{"./compare":63}],69:[function(require,module,exports){
  3715. const compare = require('./compare')
  3716. const neq = (a, b, loose) => compare(a, b, loose) !== 0
  3717. module.exports = neq
  3718.  
  3719. },{"./compare":63}],70:[function(require,module,exports){
  3720. const Range = require('../classes/range')
  3721. const satisfies = (version, range, options) => {
  3722. try {
  3723. range = new Range(range, options)
  3724. } catch (er) {
  3725. return false
  3726. }
  3727. return range.test(version)
  3728. }
  3729. module.exports = satisfies
  3730.  
  3731. },{"../classes/range":60}],71:[function(require,module,exports){
  3732. // Note: this is the semver.org version of the spec that it implements
  3733. // Not necessarily the package version of this code.
  3734. const SEMVER_SPEC_VERSION = '2.0.0'
  3735.  
  3736. const MAX_LENGTH = 256
  3737. const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
  3738. /* istanbul ignore next */ 9007199254740991
  3739.  
  3740. // Max safe segment length for coercion.
  3741. const MAX_SAFE_COMPONENT_LENGTH = 16
  3742.  
  3743. module.exports = {
  3744. SEMVER_SPEC_VERSION,
  3745. MAX_LENGTH,
  3746. MAX_SAFE_INTEGER,
  3747. MAX_SAFE_COMPONENT_LENGTH
  3748. }
  3749.  
  3750. },{}],72:[function(require,module,exports){
  3751. (function (process){
  3752. const debug = (
  3753. typeof process === 'object' &&
  3754. process.env &&
  3755. process.env.NODE_DEBUG &&
  3756. /\bsemver\b/i.test(process.env.NODE_DEBUG)
  3757. ) ? (...args) => console.error('SEMVER', ...args)
  3758. : () => {}
  3759.  
  3760. module.exports = debug
  3761.  
  3762. }).call(this,require('_process'))
  3763. },{"_process":58}],73:[function(require,module,exports){
  3764. const numeric = /^[0-9]+$/
  3765. const compareIdentifiers = (a, b) => {
  3766. const anum = numeric.test(a)
  3767. const bnum = numeric.test(b)
  3768.  
  3769. if (anum && bnum) {
  3770. a = +a
  3771. b = +b
  3772. }
  3773.  
  3774. return a === b ? 0
  3775. : (anum && !bnum) ? -1
  3776. : (bnum && !anum) ? 1
  3777. : a < b ? -1
  3778. : 1
  3779. }
  3780.  
  3781. const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a)
  3782.  
  3783. module.exports = {
  3784. compareIdentifiers,
  3785. rcompareIdentifiers
  3786. }
  3787.  
  3788. },{}],74:[function(require,module,exports){
  3789. const { MAX_SAFE_COMPONENT_LENGTH } = require('./constants')
  3790. const debug = require('./debug')
  3791. exports = module.exports = {}
  3792.  
  3793. // The actual regexps go on exports.re
  3794. const re = exports.re = []
  3795. const src = exports.src = []
  3796. const t = exports.t = {}
  3797. let R = 0
  3798.  
  3799. const createToken = (name, value, isGlobal) => {
  3800. const index = R++
  3801. debug(index, value)
  3802. t[name] = index
  3803. src[index] = value
  3804. re[index] = new RegExp(value, isGlobal ? 'g' : undefined)
  3805. }
  3806.  
  3807. // The following Regular Expressions can be used for tokenizing,
  3808. // validating, and parsing SemVer version strings.
  3809.  
  3810. // ## Numeric Identifier
  3811. // A single `0`, or a non-zero digit followed by zero or more digits.
  3812.  
  3813. createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*')
  3814. createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+')
  3815.  
  3816. // ## Non-numeric Identifier
  3817. // Zero or more digits, followed by a letter or hyphen, and then zero or
  3818. // more letters, digits, or hyphens.
  3819.  
  3820. createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*')
  3821.  
  3822. // ## Main Version
  3823. // Three dot-separated numeric identifiers.
  3824.  
  3825. createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
  3826. `(${src[t.NUMERICIDENTIFIER]})\\.` +
  3827. `(${src[t.NUMERICIDENTIFIER]})`)
  3828.  
  3829. createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
  3830. `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
  3831. `(${src[t.NUMERICIDENTIFIERLOOSE]})`)
  3832.  
  3833. // ## Pre-release Version Identifier
  3834. // A numeric identifier, or a non-numeric identifier.
  3835.  
  3836. createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
  3837. }|${src[t.NONNUMERICIDENTIFIER]})`)
  3838.  
  3839. createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
  3840. }|${src[t.NONNUMERICIDENTIFIER]})`)
  3841.  
  3842. // ## Pre-release Version
  3843. // Hyphen, followed by one or more dot-separated pre-release version
  3844. // identifiers.
  3845.  
  3846. createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
  3847. }(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`)
  3848.  
  3849. createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
  3850. }(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`)
  3851.  
  3852. // ## Build Metadata Identifier
  3853. // Any combination of digits, letters, or hyphens.
  3854.  
  3855. createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+')
  3856.  
  3857. // ## Build Metadata
  3858. // Plus sign, followed by one or more period-separated build metadata
  3859. // identifiers.
  3860.  
  3861. createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
  3862. }(?:\\.${src[t.BUILDIDENTIFIER]})*))`)
  3863.  
  3864. // ## Full Version String
  3865. // A main version, followed optionally by a pre-release version and
  3866. // build metadata.
  3867.  
  3868. // Note that the only major, minor, patch, and pre-release sections of
  3869. // the version string are capturing groups. The build metadata is not a
  3870. // capturing group, because it should not ever be used in version
  3871. // comparison.
  3872.  
  3873. createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
  3874. }${src[t.PRERELEASE]}?${
  3875. src[t.BUILD]}?`)
  3876.  
  3877. createToken('FULL', `^${src[t.FULLPLAIN]}$`)
  3878.  
  3879. // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
  3880. // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
  3881. // common in the npm registry.
  3882. createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
  3883. }${src[t.PRERELEASELOOSE]}?${
  3884. src[t.BUILD]}?`)
  3885.  
  3886. createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`)
  3887.  
  3888. createToken('GTLT', '((?:<|>)?=?)')
  3889.  
  3890. // Something like "2.*" or "1.2.x".
  3891. // Note that "x.x" is a valid xRange identifer, meaning "any version"
  3892. // Only the first item is strictly required.
  3893. createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`)
  3894. createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`)
  3895.  
  3896. createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
  3897. `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
  3898. `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
  3899. `(?:${src[t.PRERELEASE]})?${
  3900. src[t.BUILD]}?` +
  3901. `)?)?`)
  3902.  
  3903. createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
  3904. `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
  3905. `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
  3906. `(?:${src[t.PRERELEASELOOSE]})?${
  3907. src[t.BUILD]}?` +
  3908. `)?)?`)
  3909.  
  3910. createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`)
  3911. createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`)
  3912.  
  3913. // Coercion.
  3914. // Extract anything that could conceivably be a part of a valid semver
  3915. createToken('COERCE', `${'(^|[^\\d])' +
  3916. '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
  3917. `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
  3918. `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
  3919. `(?:$|[^\\d])`)
  3920. createToken('COERCERTL', src[t.COERCE], true)
  3921.  
  3922. // Tilde ranges.
  3923. // Meaning is "reasonably at or greater than"
  3924. createToken('LONETILDE', '(?:~>?)')
  3925.  
  3926. createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true)
  3927. exports.tildeTrimReplace = '$1~'
  3928.  
  3929. createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`)
  3930. createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`)
  3931.  
  3932. // Caret ranges.
  3933. // Meaning is "at least and backwards compatible with"
  3934. createToken('LONECARET', '(?:\\^)')
  3935.  
  3936. createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true)
  3937. exports.caretTrimReplace = '$1^'
  3938.  
  3939. createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`)
  3940. createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`)
  3941.  
  3942. // A simple gt/lt/eq thing, or just "" to indicate "any version"
  3943. createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`)
  3944. createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`)
  3945.  
  3946. // An expression to strip any whitespace between the gtlt and the thing
  3947. // it modifies, so that `> 1.2.3` ==> `>1.2.3`
  3948. createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
  3949. }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true)
  3950. exports.comparatorTrimReplace = '$1$2$3'
  3951.  
  3952. // Something like `1.2.3 - 1.2.4`
  3953. // Note that these all use the loose form, because they'll be
  3954. // checked against either the strict or loose comparator form
  3955. // later.
  3956. createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
  3957. `\\s+-\\s+` +
  3958. `(${src[t.XRANGEPLAIN]})` +
  3959. `\\s*$`)
  3960.  
  3961. createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
  3962. `\\s+-\\s+` +
  3963. `(${src[t.XRANGEPLAINLOOSE]})` +
  3964. `\\s*$`)
  3965.  
  3966. // Star ranges basically just allow anything at all.
  3967. createToken('STAR', '(<|>)?=?\\s*\\*')
  3968. // >=0.0.0 is like a star
  3969. createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$')
  3970. createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$')
  3971.  
  3972. },{"./constants":71,"./debug":72}]},{},[25]);