linkify-plus-plus-core

A JavaScript library for linkification stuff. Used by linkify-plus-plus.

目前为 2019-02-17 提交的版本,查看 最新版本

此脚本不应直接安装,它是供其他脚本使用的外部库。如果你需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/27630/671353/linkify-plus-plus-core.js

  1. var linkifyPlusPlusCore = (function (exports) {
  2. 'use strict';
  3.  
  4. var maxLength = 22;
  5. var chars = "セール佛山ಭಾರತ慈善集团在线한국ଭାରତভাৰত八卦موقعবংল公益司香格里拉网站移动我爱你москвақзнлйтрбгеקוםファッションストアசிங்கபூர商标店城дию新闻家電中文信国國娱乐భారత్ලංකා购物クラウドभारतम्ोसंगठन餐厅络у港食品飞利浦台湾灣手机الجزئرنیتبيپکسدظةڀ澳門닷컴شكგე构健康ไทย招聘фみんなελ世界書籍ഭാരതംਭਾਰਤ址넷コム游戏企业息嘉大酒صط广东இலைநதயாհայ加坡ف政务";
  6. var table = {
  7. aarp: true,
  8. abb: true,
  9. abbott: true,
  10. abc: true,
  11. able: true,
  12. abogado: true,
  13. abudhabi: true,
  14. ac: true,
  15. academy: true,
  16. accenture: true,
  17. accountant: true,
  18. accountants: true,
  19. aco: true,
  20. actor: true,
  21. ad: true,
  22. adult: true,
  23. ae: true,
  24. aeg: true,
  25. aero: true,
  26. aetna: true,
  27. af: true,
  28. afamilycompany: true,
  29. afl: true,
  30. africa: true,
  31. ag: true,
  32. agency: true,
  33. ai: true,
  34. aig: true,
  35. airbus: true,
  36. airforce: true,
  37. al: true,
  38. allfinanz: true,
  39. allstate: true,
  40. alsace: true,
  41. am: true,
  42. americanexpress: true,
  43. amex: true,
  44. amfam: true,
  45. amica: true,
  46. amsterdam: true,
  47. analytics: true,
  48. anz: true,
  49. ao: true,
  50. aol: true,
  51. apartments: true,
  52. app: true,
  53. apple: true,
  54. aq: true,
  55. aquarelle: true,
  56. ar: true,
  57. archi: true,
  58. army: true,
  59. arpa: true,
  60. art: true,
  61. arte: true,
  62. as: true,
  63. asia: true,
  64. associates: true,
  65. at: true,
  66. attorney: true,
  67. au: true,
  68. auction: true,
  69. audi: true,
  70. audio: true,
  71. auspost: true,
  72. auto: true,
  73. autos: true,
  74. aw: true,
  75. aws: true,
  76. ax: true,
  77. axa: true,
  78. az: true,
  79. azure: true,
  80. ba: true,
  81. baby: true,
  82. baidu: true,
  83. band: true,
  84. bank: true,
  85. bar: true,
  86. barcelona: true,
  87. barclaycard: true,
  88. barclays: true,
  89. barefoot: true,
  90. bargains: true,
  91. basketball: true,
  92. bauhaus: true,
  93. bayern: true,
  94. bb: true,
  95. bbc: true,
  96. bbt: true,
  97. bbva: true,
  98. bd: true,
  99. be: true,
  100. beer: true,
  101. bentley: true,
  102. berlin: true,
  103. best: true,
  104. bet: true,
  105. bf: true,
  106. bg: true,
  107. bh: true,
  108. bi: true,
  109. bible: true,
  110. bid: true,
  111. bike: true,
  112. bing: true,
  113. bingo: true,
  114. bio: true,
  115. biz: true,
  116. bj: true,
  117. black: true,
  118. blackfriday: true,
  119. blog: true,
  120. bloomberg: true,
  121. blue: true,
  122. bm: true,
  123. bms: true,
  124. bmw: true,
  125. bn: true,
  126. bnpparibas: true,
  127. bo: true,
  128. boats: true,
  129. bofa: true,
  130. bosch: true,
  131. bostik: true,
  132. boston: true,
  133. bot: true,
  134. boutique: true,
  135. br: true,
  136. bradesco: true,
  137. bridgestone: true,
  138. broadway: true,
  139. broker: true,
  140. brother: true,
  141. brussels: true,
  142. bs: true,
  143. bt: true,
  144. bugatti: true,
  145. build: true,
  146. builders: true,
  147. business: true,
  148. buzz: true,
  149. bw: true,
  150. by: true,
  151. bz: true,
  152. bzh: true,
  153. ca: true,
  154. cab: true,
  155. cafe: true,
  156. cam: true,
  157. camera: true,
  158. camp: true,
  159. cancerresearch: true,
  160. canon: true,
  161. capetown: true,
  162. capital: true,
  163. car: true,
  164. cards: true,
  165. care: true,
  166. career: true,
  167. careers: true,
  168. cars: true,
  169. casa: true,
  170. cash: true,
  171. casino: true,
  172. cat: true,
  173. catering: true,
  174. catholic: true,
  175. cba: true,
  176. cc: true,
  177. cd: true,
  178. center: true,
  179. ceo: true,
  180. cern: true,
  181. cf: true,
  182. cfa: true,
  183. cfd: true,
  184. cg: true,
  185. ch: true,
  186. chanel: true,
  187. charity: true,
  188. chase: true,
  189. chat: true,
  190. cheap: true,
  191. chintai: true,
  192. christmas: true,
  193. church: true,
  194. ci: true,
  195. cisco: true,
  196. citi: true,
  197. citic: true,
  198. city: true,
  199. ck: true,
  200. cl: true,
  201. claims: true,
  202. cleaning: true,
  203. click: true,
  204. clinic: true,
  205. clothing: true,
  206. cloud: true,
  207. club: true,
  208. clubmed: true,
  209. cm: true,
  210. cn: true,
  211. co: true,
  212. coach: true,
  213. codes: true,
  214. coffee: true,
  215. college: true,
  216. cologne: true,
  217. com: true,
  218. commbank: true,
  219. community: true,
  220. company: true,
  221. computer: true,
  222. condos: true,
  223. construction: true,
  224. consulting: true,
  225. contractors: true,
  226. cooking: true,
  227. cookingchannel: true,
  228. cool: true,
  229. coop: true,
  230. corsica: true,
  231. country: true,
  232. coupons: true,
  233. courses: true,
  234. cr: true,
  235. credit: true,
  236. creditcard: true,
  237. creditunion: true,
  238. cricket: true,
  239. crown: true,
  240. crs: true,
  241. cruises: true,
  242. csc: true,
  243. cu: true,
  244. cuisinella: true,
  245. cv: true,
  246. cw: true,
  247. cx: true,
  248. cy: true,
  249. cymru: true,
  250. cz: true,
  251. dabur: true,
  252. dance: true,
  253. date: true,
  254. dating: true,
  255. de: true,
  256. deals: true,
  257. degree: true,
  258. delivery: true,
  259. dell: true,
  260. deloitte: true,
  261. democrat: true,
  262. dental: true,
  263. dentist: true,
  264. desi: true,
  265. design: true,
  266. dev: true,
  267. dhl: true,
  268. diamonds: true,
  269. diet: true,
  270. digital: true,
  271. direct: true,
  272. directory: true,
  273. discount: true,
  274. discover: true,
  275. diy: true,
  276. dj: true,
  277. dk: true,
  278. dm: true,
  279. dnp: true,
  280. "do": true,
  281. doctor: true,
  282. dog: true,
  283. domains: true,
  284. download: true,
  285. dubai: true,
  286. duck: true,
  287. dupont: true,
  288. durban: true,
  289. dvag: true,
  290. dz: true,
  291. earth: true,
  292. ec: true,
  293. eco: true,
  294. edeka: true,
  295. edu: true,
  296. education: true,
  297. ee: true,
  298. eg: true,
  299. email: true,
  300. emerck: true,
  301. energy: true,
  302. engineer: true,
  303. engineering: true,
  304. enterprises: true,
  305. equipment: true,
  306. er: true,
  307. ericsson: true,
  308. erni: true,
  309. es: true,
  310. estate: true,
  311. esurance: true,
  312. et: true,
  313. eu: true,
  314. eurovision: true,
  315. eus: true,
  316. events: true,
  317. everbank: true,
  318. exchange: true,
  319. expert: true,
  320. exposed: true,
  321. express: true,
  322. extraspace: true,
  323. fage: true,
  324. fail: true,
  325. fairwinds: true,
  326. faith: true,
  327. family: true,
  328. fan: true,
  329. fans: true,
  330. farm: true,
  331. fashion: true,
  332. feedback: true,
  333. ferrero: true,
  334. fi: true,
  335. fidelity: true,
  336. film: true,
  337. finance: true,
  338. financial: true,
  339. firmdale: true,
  340. fish: true,
  341. fishing: true,
  342. fit: true,
  343. fitness: true,
  344. fj: true,
  345. fk: true,
  346. flights: true,
  347. florist: true,
  348. flowers: true,
  349. fm: true,
  350. fo: true,
  351. foo: true,
  352. food: true,
  353. foodnetwork: true,
  354. football: true,
  355. ford: true,
  356. forex: true,
  357. forsale: true,
  358. forum: true,
  359. foundation: true,
  360. fox: true,
  361. fr: true,
  362. fresenius: true,
  363. frl: true,
  364. frogans: true,
  365. frontdoor: true,
  366. fujitsu: true,
  367. fujixerox: true,
  368. fun: true,
  369. fund: true,
  370. furniture: true,
  371. futbol: true,
  372. fyi: true,
  373. ga: true,
  374. gal: true,
  375. gallery: true,
  376. gallo: true,
  377. game: true,
  378. games: true,
  379. garden: true,
  380. gd: true,
  381. gdn: true,
  382. ge: true,
  383. gea: true,
  384. gent: true,
  385. genting: true,
  386. gf: true,
  387. gg: true,
  388. gh: true,
  389. gi: true,
  390. gift: true,
  391. gifts: true,
  392. gives: true,
  393. gl: true,
  394. glade: true,
  395. glass: true,
  396. gle: true,
  397. global: true,
  398. globo: true,
  399. gm: true,
  400. gmail: true,
  401. gmbh: true,
  402. gmo: true,
  403. gmx: true,
  404. gn: true,
  405. gold: true,
  406. golf: true,
  407. goo: true,
  408. goog: true,
  409. google: true,
  410. gop: true,
  411. gov: true,
  412. gp: true,
  413. gq: true,
  414. gr: true,
  415. grainger: true,
  416. graphics: true,
  417. gratis: true,
  418. green: true,
  419. gripe: true,
  420. group: true,
  421. gs: true,
  422. gt: true,
  423. gu: true,
  424. guardian: true,
  425. gucci: true,
  426. guide: true,
  427. guitars: true,
  428. guru: true,
  429. gw: true,
  430. gy: true,
  431. hamburg: true,
  432. haus: true,
  433. health: true,
  434. healthcare: true,
  435. help: true,
  436. here: true,
  437. hermes: true,
  438. hgtv: true,
  439. hiphop: true,
  440. hisamitsu: true,
  441. hitachi: true,
  442. hiv: true,
  443. hk: true,
  444. hm: true,
  445. hn: true,
  446. hockey: true,
  447. holdings: true,
  448. holiday: true,
  449. homes: true,
  450. honda: true,
  451. horse: true,
  452. hospital: true,
  453. host: true,
  454. hosting: true,
  455. hoteles: true,
  456. hotmail: true,
  457. house: true,
  458. how: true,
  459. hr: true,
  460. hsbc: true,
  461. ht: true,
  462. hu: true,
  463. hyatt: true,
  464. ice: true,
  465. icu: true,
  466. id: true,
  467. ie: true,
  468. ieee: true,
  469. ifm: true,
  470. ikano: true,
  471. il: true,
  472. im: true,
  473. immo: true,
  474. immobilien: true,
  475. "in": true,
  476. inc: true,
  477. industries: true,
  478. info: true,
  479. ink: true,
  480. institute: true,
  481. insurance: true,
  482. insure: true,
  483. int: true,
  484. intel: true,
  485. international: true,
  486. investments: true,
  487. io: true,
  488. ipiranga: true,
  489. iq: true,
  490. ir: true,
  491. irish: true,
  492. is: true,
  493. iselect: true,
  494. ismaili: true,
  495. ist: true,
  496. istanbul: true,
  497. it: true,
  498. itv: true,
  499. jaguar: true,
  500. java: true,
  501. jcb: true,
  502. je: true,
  503. jetzt: true,
  504. jewelry: true,
  505. jio: true,
  506. jll: true,
  507. jm: true,
  508. jmp: true,
  509. jnj: true,
  510. jo: true,
  511. jobs: true,
  512. joburg: true,
  513. jp: true,
  514. jpmorgan: true,
  515. jprs: true,
  516. juegos: true,
  517. juniper: true,
  518. kaufen: true,
  519. ke: true,
  520. kerryhotels: true,
  521. kerrylogistics: true,
  522. kerryproperties: true,
  523. kfh: true,
  524. kg: true,
  525. kh: true,
  526. ki: true,
  527. kia: true,
  528. kim: true,
  529. kinder: true,
  530. kitchen: true,
  531. kiwi: true,
  532. km: true,
  533. kn: true,
  534. koeln: true,
  535. komatsu: true,
  536. kp: true,
  537. kpmg: true,
  538. kpn: true,
  539. kr: true,
  540. krd: true,
  541. kred: true,
  542. kuokgroup: true,
  543. kw: true,
  544. ky: true,
  545. kyoto: true,
  546. kz: true,
  547. la: true,
  548. ladbrokes: true,
  549. lamborghini: true,
  550. lancaster: true,
  551. land: true,
  552. landrover: true,
  553. lanxess: true,
  554. lat: true,
  555. latrobe: true,
  556. law: true,
  557. lawyer: true,
  558. lb: true,
  559. lc: true,
  560. lease: true,
  561. leclerc: true,
  562. lefrak: true,
  563. legal: true,
  564. lego: true,
  565. lexus: true,
  566. lgbt: true,
  567. li: true,
  568. liaison: true,
  569. lidl: true,
  570. life: true,
  571. lighting: true,
  572. lilly: true,
  573. limited: true,
  574. limo: true,
  575. linde: true,
  576. link: true,
  577. lipsy: true,
  578. live: true,
  579. lixil: true,
  580. lk: true,
  581. llc: true,
  582. loan: true,
  583. loans: true,
  584. locus: true,
  585. lol: true,
  586. london: true,
  587. lotto: true,
  588. love: true,
  589. lr: true,
  590. ls: true,
  591. lt: true,
  592. ltd: true,
  593. ltda: true,
  594. lu: true,
  595. lundbeck: true,
  596. lupin: true,
  597. luxe: true,
  598. luxury: true,
  599. lv: true,
  600. ly: true,
  601. ma: true,
  602. madrid: true,
  603. maif: true,
  604. maison: true,
  605. makeup: true,
  606. man: true,
  607. management: true,
  608. mango: true,
  609. market: true,
  610. marketing: true,
  611. markets: true,
  612. marriott: true,
  613. mattel: true,
  614. mba: true,
  615. mc: true,
  616. md: true,
  617. me: true,
  618. med: true,
  619. media: true,
  620. meet: true,
  621. melbourne: true,
  622. memorial: true,
  623. men: true,
  624. menu: true,
  625. mg: true,
  626. mh: true,
  627. miami: true,
  628. microsoft: true,
  629. mil: true,
  630. mini: true,
  631. mit: true,
  632. mk: true,
  633. ml: true,
  634. mlb: true,
  635. mm: true,
  636. mma: true,
  637. mn: true,
  638. mo: true,
  639. mobi: true,
  640. moda: true,
  641. moe: true,
  642. moi: true,
  643. mom: true,
  644. monash: true,
  645. money: true,
  646. monster: true,
  647. mortgage: true,
  648. moscow: true,
  649. motorcycles: true,
  650. movie: true,
  651. mp: true,
  652. mq: true,
  653. mr: true,
  654. ms: true,
  655. mt: true,
  656. mtn: true,
  657. mtr: true,
  658. mu: true,
  659. museum: true,
  660. mutual: true,
  661. mv: true,
  662. mw: true,
  663. mx: true,
  664. my: true,
  665. mz: true,
  666. na: true,
  667. nab: true,
  668. nadex: true,
  669. nagoya: true,
  670. name: true,
  671. nationwide: true,
  672. natura: true,
  673. navy: true,
  674. nc: true,
  675. ne: true,
  676. nec: true,
  677. net: true,
  678. netbank: true,
  679. network: true,
  680. neustar: true,
  681. "new": true,
  682. news: true,
  683. next: true,
  684. nextdirect: true,
  685. nf: true,
  686. ng: true,
  687. ngo: true,
  688. ni: true,
  689. nico: true,
  690. nikon: true,
  691. ninja: true,
  692. nissan: true,
  693. nissay: true,
  694. nl: true,
  695. no: true,
  696. nokia: true,
  697. northwesternmutual: true,
  698. norton: true,
  699. nowruz: true,
  700. np: true,
  701. nr: true,
  702. nra: true,
  703. nrw: true,
  704. ntt: true,
  705. nu: true,
  706. nyc: true,
  707. nz: true,
  708. obi: true,
  709. observer: true,
  710. off: true,
  711. okinawa: true,
  712. om: true,
  713. omega: true,
  714. one: true,
  715. ong: true,
  716. onl: true,
  717. online: true,
  718. onyourside: true,
  719. ooo: true,
  720. oracle: true,
  721. orange: true,
  722. org: true,
  723. organic: true,
  724. osaka: true,
  725. otsuka: true,
  726. ovh: true,
  727. pa: true,
  728. page: true,
  729. paris: true,
  730. partners: true,
  731. parts: true,
  732. party: true,
  733. pe: true,
  734. pet: true,
  735. pf: true,
  736. pfizer: true,
  737. pg: true,
  738. ph: true,
  739. pharmacy: true,
  740. philips: true,
  741. photo: true,
  742. photography: true,
  743. photos: true,
  744. physio: true,
  745. pics: true,
  746. pictet: true,
  747. pictures: true,
  748. pink: true,
  749. pioneer: true,
  750. pizza: true,
  751. pk: true,
  752. pl: true,
  753. place: true,
  754. plumbing: true,
  755. plus: true,
  756. pm: true,
  757. pn: true,
  758. poker: true,
  759. porn: true,
  760. post: true,
  761. pr: true,
  762. praxi: true,
  763. press: true,
  764. pro: true,
  765. productions: true,
  766. promo: true,
  767. properties: true,
  768. property: true,
  769. protection: true,
  770. pru: true,
  771. prudential: true,
  772. ps: true,
  773. pt: true,
  774. pub: true,
  775. pw: true,
  776. py: true,
  777. qa: true,
  778. qpon: true,
  779. quebec: true,
  780. racing: true,
  781. radio: true,
  782. raid: true,
  783. re: true,
  784. realestate: true,
  785. realtor: true,
  786. realty: true,
  787. recipes: true,
  788. red: true,
  789. redstone: true,
  790. rehab: true,
  791. reise: true,
  792. reisen: true,
  793. reit: true,
  794. ren: true,
  795. rent: true,
  796. rentals: true,
  797. repair: true,
  798. report: true,
  799. republican: true,
  800. rest: true,
  801. restaurant: true,
  802. review: true,
  803. reviews: true,
  804. rexroth: true,
  805. rich: true,
  806. ricoh: true,
  807. rio: true,
  808. rip: true,
  809. rmit: true,
  810. ro: true,
  811. rocks: true,
  812. rodeo: true,
  813. rs: true,
  814. ru: true,
  815. rugby: true,
  816. ruhr: true,
  817. run: true,
  818. rw: true,
  819. rwe: true,
  820. ryukyu: true,
  821. sa: true,
  822. saarland: true,
  823. sale: true,
  824. salon: true,
  825. samsung: true,
  826. sandvik: true,
  827. sandvikcoromant: true,
  828. sanofi: true,
  829. sap: true,
  830. sarl: true,
  831. saxo: true,
  832. sb: true,
  833. sbi: true,
  834. sbs: true,
  835. sc: true,
  836. sca: true,
  837. scb: true,
  838. schaeffler: true,
  839. schmidt: true,
  840. school: true,
  841. schule: true,
  842. schwarz: true,
  843. science: true,
  844. scjohnson: true,
  845. scot: true,
  846. sd: true,
  847. se: true,
  848. seat: true,
  849. security: true,
  850. sener: true,
  851. services: true,
  852. ses: true,
  853. seven: true,
  854. sew: true,
  855. sex: true,
  856. sexy: true,
  857. sfr: true,
  858. sg: true,
  859. sh: true,
  860. shangrila: true,
  861. sharp: true,
  862. shell: true,
  863. shiksha: true,
  864. shoes: true,
  865. shop: true,
  866. shopping: true,
  867. show: true,
  868. shriram: true,
  869. si: true,
  870. singles: true,
  871. site: true,
  872. sk: true,
  873. ski: true,
  874. skin: true,
  875. sky: true,
  876. skype: true,
  877. sl: true,
  878. sm: true,
  879. smart: true,
  880. sn: true,
  881. sncf: true,
  882. so: true,
  883. soccer: true,
  884. social: true,
  885. softbank: true,
  886. software: true,
  887. sohu: true,
  888. solar: true,
  889. solutions: true,
  890. sony: true,
  891. soy: true,
  892. space: true,
  893. sport: true,
  894. spreadbetting: true,
  895. sr: true,
  896. srl: true,
  897. ss: true,
  898. st: true,
  899. stada: true,
  900. statebank: true,
  901. statefarm: true,
  902. stc: true,
  903. stockholm: true,
  904. storage: true,
  905. store: true,
  906. stream: true,
  907. studio: true,
  908. study: true,
  909. style: true,
  910. su: true,
  911. sucks: true,
  912. supplies: true,
  913. supply: true,
  914. support: true,
  915. surf: true,
  916. surgery: true,
  917. suzuki: true,
  918. sv: true,
  919. swatch: true,
  920. swiss: true,
  921. sx: true,
  922. sy: true,
  923. sydney: true,
  924. symantec: true,
  925. systems: true,
  926. sz: true,
  927. taipei: true,
  928. tatamotors: true,
  929. tatar: true,
  930. tattoo: true,
  931. tax: true,
  932. taxi: true,
  933. tc: true,
  934. td: true,
  935. team: true,
  936. tech: true,
  937. technology: true,
  938. tel: true,
  939. temasek: true,
  940. tennis: true,
  941. teva: true,
  942. tf: true,
  943. tg: true,
  944. th: true,
  945. theater: true,
  946. theatre: true,
  947. tiaa: true,
  948. tickets: true,
  949. tienda: true,
  950. tiffany: true,
  951. tips: true,
  952. tires: true,
  953. tirol: true,
  954. tj: true,
  955. tk: true,
  956. tl: true,
  957. tm: true,
  958. tn: true,
  959. to: true,
  960. today: true,
  961. tokyo: true,
  962. tools: true,
  963. top: true,
  964. toray: true,
  965. total: true,
  966. tours: true,
  967. town: true,
  968. toyota: true,
  969. toys: true,
  970. tr: true,
  971. trade: true,
  972. trading: true,
  973. training: true,
  974. travel: true,
  975. travelchannel: true,
  976. travelers: true,
  977. trust: true,
  978. tt: true,
  979. tube: true,
  980. tv: true,
  981. tw: true,
  982. tz: true,
  983. ua: true,
  984. ubank: true,
  985. ubs: true,
  986. ug: true,
  987. uk: true,
  988. university: true,
  989. uno: true,
  990. uol: true,
  991. us: true,
  992. uy: true,
  993. uz: true,
  994. va: true,
  995. vacations: true,
  996. vanguard: true,
  997. vc: true,
  998. ve: true,
  999. vegas: true,
  1000. ventures: true,
  1001. versicherung: true,
  1002. vet: true,
  1003. vg: true,
  1004. vi: true,
  1005. viajes: true,
  1006. video: true,
  1007. villas: true,
  1008. vin: true,
  1009. vip: true,
  1010. visa: true,
  1011. vision: true,
  1012. vistaprint: true,
  1013. vivo: true,
  1014. vlaanderen: true,
  1015. vn: true,
  1016. vodka: true,
  1017. volkswagen: true,
  1018. volvo: true,
  1019. vote: true,
  1020. voting: true,
  1021. voto: true,
  1022. voyage: true,
  1023. vu: true,
  1024. wales: true,
  1025. walter: true,
  1026. wang: true,
  1027. warman: true,
  1028. watch: true,
  1029. webcam: true,
  1030. weber: true,
  1031. website: true,
  1032. wed: true,
  1033. wedding: true,
  1034. weir: true,
  1035. wf: true,
  1036. whoswho: true,
  1037. wien: true,
  1038. wiki: true,
  1039. williamhill: true,
  1040. win: true,
  1041. windows: true,
  1042. wine: true,
  1043. wme: true,
  1044. woodside: true,
  1045. work: true,
  1046. works: true,
  1047. world: true,
  1048. ws: true,
  1049. wtf: true,
  1050. xbox: true,
  1051. xerox: true,
  1052. xin: true,
  1053. "xn--1ck2e1b": true,
  1054. "xn--1qqw23a": true,
  1055. "xn--2scrj9c": true,
  1056. "xn--30rr7y": true,
  1057. "xn--3bst00m": true,
  1058. "xn--3ds443g": true,
  1059. "xn--3e0b707e": true,
  1060. "xn--3hcrj9c": true,
  1061. "xn--45br5cyl": true,
  1062. "xn--45q11c": true,
  1063. "xn--4gbrim": true,
  1064. "xn--54b7fta0cc": true,
  1065. "xn--55qw42g": true,
  1066. "xn--55qx5d": true,
  1067. "xn--5su34j936bgsg": true,
  1068. "xn--5tzm5g": true,
  1069. "xn--6frz82g": true,
  1070. "xn--6qq986b3xl": true,
  1071. "xn--80adxhks": true,
  1072. "xn--80ao21a": true,
  1073. "xn--80asehdb": true,
  1074. "xn--80aswg": true,
  1075. "xn--90a3ac": true,
  1076. "xn--90ae": true,
  1077. "xn--90ais": true,
  1078. "xn--9dbq2a": true,
  1079. "xn--bck1b9a5dre4c": true,
  1080. "xn--c1avg": true,
  1081. "xn--cck2b3b": true,
  1082. "xn--clchc0ea0b2g2a9gcd": true,
  1083. "xn--czr694b": true,
  1084. "xn--czrs0t": true,
  1085. "xn--czru2d": true,
  1086. "xn--d1acj3b": true,
  1087. "xn--d1alf": true,
  1088. "xn--e1a4c": true,
  1089. "xn--efvy88h": true,
  1090. "xn--fct429k": true,
  1091. "xn--fiq228c5hs": true,
  1092. "xn--fiq64b": true,
  1093. "xn--fiqs8s": true,
  1094. "xn--fiqz9s": true,
  1095. "xn--fjq720a": true,
  1096. "xn--fpcrj9c3d": true,
  1097. "xn--fzc2c9e2c": true,
  1098. "xn--g2xx48c": true,
  1099. "xn--gckr3f0f": true,
  1100. "xn--h2breg3eve": true,
  1101. "xn--h2brj9c": true,
  1102. "xn--h2brj9c8c": true,
  1103. "xn--hxt814e": true,
  1104. "xn--i1b6b1a6a2e": true,
  1105. "xn--imr513n": true,
  1106. "xn--io0a7i": true,
  1107. "xn--j1amh": true,
  1108. "xn--j6w193g": true,
  1109. "xn--jvr189m": true,
  1110. "xn--kcrx77d1x4a": true,
  1111. "xn--kprw13d": true,
  1112. "xn--kpry57d": true,
  1113. "xn--kput3i": true,
  1114. "xn--l1acc": true,
  1115. "xn--lgbbat1ad8j": true,
  1116. "xn--mgb9awbf": true,
  1117. "xn--mgba3a4f16a": true,
  1118. "xn--mgbaam7a8h": true,
  1119. "xn--mgbab2bd": true,
  1120. "xn--mgbah1a3hjkrd": true,
  1121. "xn--mgbai9azgqp6j": true,
  1122. "xn--mgbayh7gpa": true,
  1123. "xn--mgbbh1a": true,
  1124. "xn--mgbca7dzdo": true,
  1125. "xn--mgberp4a5d4ar": true,
  1126. "xn--mgbgu82a": true,
  1127. "xn--mgbpl2fh": true,
  1128. "xn--mgbtx2b": true,
  1129. "xn--mix891f": true,
  1130. "xn--mk1bu44c": true,
  1131. "xn--ngbc5azd": true,
  1132. "xn--node": true,
  1133. "xn--nqv7f": true,
  1134. "xn--nyqy26a": true,
  1135. "xn--o3cw4h": true,
  1136. "xn--ogbpf8fl": true,
  1137. "xn--otu796d": true,
  1138. "xn--p1acf": true,
  1139. "xn--p1ai": true,
  1140. "xn--pgbs0dh": true,
  1141. "xn--q9jyb4c": true,
  1142. "xn--qxam": true,
  1143. "xn--rhqv96g": true,
  1144. "xn--rovu88b": true,
  1145. "xn--rvc1e0am3e": true,
  1146. "xn--s9brj9c": true,
  1147. "xn--ses554g": true,
  1148. "xn--t60b56a": true,
  1149. "xn--tckwe": true,
  1150. "xn--unup4y": true,
  1151. "xn--vhquv": true,
  1152. "xn--vuq861b": true,
  1153. "xn--w4r85el8fhu5dnra": true,
  1154. "xn--w4rs40l": true,
  1155. "xn--wgbh1c": true,
  1156. "xn--wgbl6a": true,
  1157. "xn--xhq521b": true,
  1158. "xn--xkc2al3hye2a": true,
  1159. "xn--xkc2dl3a5ee0h": true,
  1160. "xn--y9a3aq": true,
  1161. "xn--yfro4i67o": true,
  1162. "xn--ygbi2ammx": true,
  1163. "xn--zfr164b": true,
  1164. xxx: true,
  1165. xyz: true,
  1166. yachts: true,
  1167. yandex: true,
  1168. ye: true,
  1169. yoga: true,
  1170. yokohama: true,
  1171. youtube: true,
  1172. yt: true,
  1173. za: true,
  1174. zara: true,
  1175. zm: true,
  1176. zone: true,
  1177. zw: true,
  1178. "セール": true,
  1179. "佛山": true,
  1180. "ಭಾರತ": true,
  1181. "慈善": true,
  1182. "集团": true,
  1183. "在线": true,
  1184. "한국": true,
  1185. "ଭାରତ": true,
  1186. "ভাৰত": true,
  1187. "八卦": true,
  1188. "موقع": true,
  1189. "বাংলা": true,
  1190. "公益": true,
  1191. "公司": true,
  1192. "香格里拉": true,
  1193. "网站": true,
  1194. "移动": true,
  1195. "我爱你": true,
  1196. "москва": true,
  1197. "қаз": true,
  1198. "онлайн": true,
  1199. "сайт": true,
  1200. "срб": true,
  1201. "бг": true,
  1202. "бел": true,
  1203. "קום": true,
  1204. "ファッション": true,
  1205. "орг": true,
  1206. "ストア": true,
  1207. "சிங்கப்பூர்": true,
  1208. "商标": true,
  1209. "商店": true,
  1210. "商城": true,
  1211. "дети": true,
  1212. "мкд": true,
  1213. "ею": true,
  1214. "新闻": true,
  1215. "家電": true,
  1216. "中文网": true,
  1217. "中信": true,
  1218. "中国": true,
  1219. "中國": true,
  1220. "娱乐": true,
  1221. "భారత్": true,
  1222. "ලංකා": true,
  1223. "购物": true,
  1224. "クラウド": true,
  1225. "भारतम्": true,
  1226. "भारत": true,
  1227. "भारोत": true,
  1228. "网店": true,
  1229. "संगठन": true,
  1230. "餐厅": true,
  1231. "网络": true,
  1232. "укр": true,
  1233. "香港": true,
  1234. "食品": true,
  1235. "飞利浦": true,
  1236. "台湾": true,
  1237. "台灣": true,
  1238. "手机": true,
  1239. "мон": true,
  1240. "الجزائر": true,
  1241. "عمان": true,
  1242. "ایران": true,
  1243. "امارات": true,
  1244. "بازار": true,
  1245. "موريتانيا": true,
  1246. "پاکستان": true,
  1247. "الاردن": true,
  1248. "بارت": true,
  1249. "ابوظبي": true,
  1250. "السعودية": true,
  1251. "ڀارت": true,
  1252. "سودان": true,
  1253. "عراق": true,
  1254. "澳門": true,
  1255. "닷컴": true,
  1256. "شبكة": true,
  1257. "გე": true,
  1258. "机构": true,
  1259. "健康": true,
  1260. "ไทย": true,
  1261. "سورية": true,
  1262. "招聘": true,
  1263. "рус": true,
  1264. "рф": true,
  1265. "تونس": true,
  1266. "みんな": true,
  1267. "ελ": true,
  1268. "世界": true,
  1269. "書籍": true,
  1270. "ഭാരതം": true,
  1271. "ਭਾਰਤ": true,
  1272. "网址": true,
  1273. "닷넷": true,
  1274. "コム": true,
  1275. "游戏": true,
  1276. "企业": true,
  1277. "信息": true,
  1278. "嘉里大酒店": true,
  1279. "嘉里": true,
  1280. "مصر": true,
  1281. "قطر": true,
  1282. "广东": true,
  1283. "இலங்கை": true,
  1284. "இந்தியா": true,
  1285. "հայ": true,
  1286. "新加坡": true,
  1287. "فلسطين": true,
  1288. "政务": true
  1289. };
  1290.  
  1291. var RE = {
  1292. PROTOCOL: "([a-z][-a-z*]+://)?",
  1293. USER: "(?:([\\w:.+-]+)@)?",
  1294. DOMAIN_UNI: `([a-z0-9-.\\u00A0-\\uFFFF]+\\.[a-z0-9-${chars}]{1,${maxLength}})`,
  1295. DOMAIN: `([a-z0-9-.]+\\.[a-z0-9-]{1,${maxLength}})`,
  1296. PORT: "(:\\d+\\b)?",
  1297. PATH_UNI: "([/?#]\\S*)?",
  1298. PATH: "([/?#][\\w-.~!$&*+;=:@%/?#(),'\\[\\]]*)?"
  1299. },
  1300. TLD_TABLE = table;
  1301.  
  1302. function regexEscape(text) {
  1303. return text.replace(/[[\]\\^-]/g, "\\$&");
  1304. }
  1305.  
  1306. function buildRegex({
  1307. unicode = false, customRules = [], standalone = false,
  1308. boundaryLeft, boundaryRight
  1309. }) {
  1310. var pattern = RE.PROTOCOL + RE.USER;
  1311. if (unicode) {
  1312. pattern += RE.DOMAIN_UNI + RE.PORT + RE.PATH_UNI;
  1313. } else {
  1314. pattern += RE.DOMAIN + RE.PORT + RE.PATH;
  1315. }
  1316. if (customRules.length) {
  1317. pattern = "(?:" + pattern + "|(" + customRules.join("|") + "))";
  1318. } else {
  1319. pattern += "()";
  1320. }
  1321. var prefix, suffix, invalidSuffix;
  1322. if (standalone) {
  1323. if (boundaryLeft) {
  1324. prefix = "((?:^|\\s)[" + regexEscape(boundaryLeft) + "]*?)";
  1325. } else {
  1326. prefix = "(^|\\s)";
  1327. }
  1328. if (boundaryRight) {
  1329. suffix = "([" + regexEscape(boundaryRight) + "]*(?:$|\\s))";
  1330. } else {
  1331. suffix = "($|\\s)";
  1332. }
  1333. invalidSuffix = "[^\\s" + regexEscape(boundaryRight) + "]";
  1334. } else {
  1335. prefix = "(^|\\b|_)";
  1336. suffix = "()";
  1337. }
  1338. pattern = prefix + pattern + suffix;
  1339. return {
  1340. url: new RegExp(pattern, "igm"),
  1341. invalidSuffix: invalidSuffix && new RegExp(invalidSuffix),
  1342. mustache: /\{\{[\s\S]+?\}\}/g
  1343. };
  1344. }
  1345.  
  1346. function pathStrip(m, re, repl) {
  1347. var s = m.path.replace(re, repl);
  1348.  
  1349. if (s == m.path) return;
  1350. m.end -= m.path.length - s.length;
  1351. m.suffix = m.path.slice(s.length) + m.suffix;
  1352. m.path = s;
  1353. }
  1354.  
  1355. function pathStripQuote(m, c) {
  1356. var i = 0, s = m.path, end, pos = 0;
  1357. if (!s.endsWith(c)) return;
  1358. while ((pos = s.indexOf(c, pos)) >= 0) {
  1359. if (i % 2) {
  1360. end = null;
  1361. } else {
  1362. end = pos;
  1363. }
  1364. pos++;
  1365. i++;
  1366. }
  1367. if (!end) return;
  1368. m.end -= s.length - end;
  1369. m.path = s.slice(0, end);
  1370. m.suffix = s.slice(end) + m.suffix;
  1371. }
  1372.  
  1373. function pathStripBrace(m, left, right) {
  1374. var str = m.path,
  1375. re = new RegExp("[\\" + left + "\\" + right + "]", "g"),
  1376. match, count = 0, end;
  1377.  
  1378. // Match loop
  1379. while ((match = re.exec(str))) {
  1380. if (count % 2 == 0) {
  1381. end = match.index;
  1382. if (match[0] == right) {
  1383. break;
  1384. }
  1385. } else {
  1386. if (match[0] == left) {
  1387. break;
  1388. }
  1389. }
  1390. count++;
  1391. }
  1392.  
  1393. if (!match && count % 2 == 0) {
  1394. return;
  1395. }
  1396. m.end -= m.path.length - end;
  1397. m.path = str.slice(0, end);
  1398. m.suffix = str.slice(end) + m.suffix;
  1399. }
  1400.  
  1401. function isIP(s) {
  1402. var m, i;
  1403. if (!(m = s.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/))) {
  1404. return false;
  1405. }
  1406. for (i = 1; i < m.length; i++) {
  1407. if (+m[i] > 255 || (m[i].length > 1 && m[i][0] == "0")) {
  1408. return false;
  1409. }
  1410. }
  1411. return true;
  1412. }
  1413.  
  1414. function isDomain(d) {
  1415. return /^[^.-]/.test(d) && d.indexOf("..") < 0;
  1416. }
  1417.  
  1418. function inTLDS(domain) {
  1419. var match = domain.match(/\.([^.]+)$/);
  1420. if (!match) {
  1421. return false;
  1422. }
  1423. var key = match[1].toLowerCase();
  1424. return TLD_TABLE.hasOwnProperty(key);
  1425. }
  1426.  
  1427. class UrlMatcher {
  1428. constructor(options = {}) {
  1429. this.options = options;
  1430. this.regex = buildRegex(options);
  1431. }
  1432. *match(text) {
  1433. var {
  1434. fuzzyIp = true,
  1435. ignoreMustache = false
  1436. } = this.options,
  1437. {
  1438. url,
  1439. invalidSuffix,
  1440. mustache
  1441. } = this.regex,
  1442. urlLastIndex, mustacheLastIndex;
  1443. mustache.lastIndex = 0;
  1444. url.lastIndex = 0;
  1445. var mustacheMatch, mustacheRange;
  1446. if (ignoreMustache) {
  1447. mustacheMatch = mustache.exec(text);
  1448. if (mustacheMatch) {
  1449. mustacheRange = {
  1450. start: mustacheMatch.index,
  1451. end: mustache.lastIndex
  1452. };
  1453. }
  1454. }
  1455. var urlMatch;
  1456. while ((urlMatch = url.exec(text))) {
  1457. var result;
  1458. if (urlMatch[7]) {
  1459. // custom rules
  1460. result = {
  1461. start: urlMatch.index,
  1462. end: url.lastIndex,
  1463. text: urlMatch[0],
  1464. url: urlMatch[0],
  1465. custom: urlMatch[7]
  1466. };
  1467. } else {
  1468. result = {
  1469. start: urlMatch.index + urlMatch[1].length,
  1470. end: url.lastIndex - urlMatch[8].length,
  1471. text: null,
  1472. url: null,
  1473. prefix: urlMatch[1],
  1474. protocol: urlMatch[2],
  1475. auth: urlMatch[3] || "",
  1476. domain: urlMatch[4],
  1477. port: urlMatch[5] || "",
  1478. path: urlMatch[6] || "",
  1479. custom: urlMatch[7],
  1480. suffix: urlMatch[8]
  1481. };
  1482. }
  1483. if (mustacheRange && mustacheRange.end <= result.start) {
  1484. mustacheMatch = mustache.exec(text);
  1485. if (mustacheMatch) {
  1486. mustacheRange.start = mustacheMatch.index;
  1487. mustacheRange.end = mustache.lastIndex;
  1488. } else {
  1489. mustacheRange = null;
  1490. }
  1491. }
  1492. // ignore urls inside mustache pair
  1493. if (mustacheRange && result.start < mustacheRange.end && result.end >= mustacheRange.start) {
  1494. continue;
  1495. }
  1496. if (!result.custom) {
  1497. // adjust path and suffix
  1498. if (result.path) {
  1499. // Strip BBCode
  1500. pathStrip(result, /\[\/?(b|i|u|url|img|quote|code|size|color)\].*/i, "");
  1501. // Strip braces
  1502. pathStripBrace(result, "(", ")");
  1503. pathStripBrace(result, "[", "]");
  1504. pathStripBrace(result, "{", "}");
  1505. // Strip quotes
  1506. pathStripQuote(result, "'");
  1507. pathStripQuote(result, '"');
  1508. // Remove trailing ".,?"
  1509. pathStrip(result, /(^|[^-_])[.,?]+$/, "$1");
  1510. }
  1511. // check suffix
  1512. if (invalidSuffix && invalidSuffix.test(result.suffix)) {
  1513. if (/\s$/.test(result.suffix)) {
  1514. url.lastIndex--;
  1515. }
  1516. continue;
  1517. }
  1518. // check domain
  1519. if (isIP(result.domain)) {
  1520. if (!fuzzyIp && !result.protocol && !result.auth && !result.path) {
  1521. continue;
  1522. }
  1523. } else if (isDomain(result.domain)) {
  1524. if (!inTLDS(result.domain)) {
  1525. continue;
  1526. }
  1527. } else {
  1528. continue;
  1529. }
  1530. // mailto protocol
  1531. if (!result.protocol && result.auth) {
  1532. var matchMail = result.auth.match(/^mailto:(.+)/);
  1533. if (matchMail) {
  1534. result.protocol = "mailto:";
  1535. result.auth = matchMail[1];
  1536. }
  1537. }
  1538.  
  1539. // http alias
  1540. if (result.protocol && result.protocol.match(/^(hxxp|h\*\*p|ttp)/)) {
  1541. result.protocol = "http://";
  1542. }
  1543.  
  1544. // guess protocol
  1545. if (!result.protocol) {
  1546. var domainMatch;
  1547. if ((domainMatch = result.domain.match(/^(ftp|irc)/))) {
  1548. result.protocol = domainMatch[0] + "://";
  1549. } else if (result.domain.match(/^(www|web)/)) {
  1550. result.protocol = "http://";
  1551. } else if (result.auth && result.auth.indexOf(":") < 0 && !result.path) {
  1552. result.protocol = "mailto:";
  1553. } else {
  1554. result.protocol = "http://";
  1555. }
  1556. }
  1557.  
  1558. // Create URL
  1559. result.url = result.protocol + (result.auth && result.auth + "@") + result.domain + result.port + result.path;
  1560. result.text = text.slice(result.start, result.end);
  1561. }
  1562. // since regex is shared with other parse generators, cache lastIndex position and restore later
  1563. mustacheLastIndex = mustache.lastIndex;
  1564. urlLastIndex = url.lastIndex;
  1565. yield result;
  1566. url.lastIndex = urlLastIndex;
  1567. mustache.lastIndex = mustacheLastIndex;
  1568. }
  1569. }
  1570. }
  1571.  
  1572. /**
  1573. * event-lite.js - Light-weight EventEmitter (less than 1KB when gzipped)
  1574. *
  1575. * @copyright Yusuke Kawasaki
  1576. * @license MIT
  1577. * @constructor
  1578. * @see https://github.com/kawanet/event-lite
  1579. * @see http://kawanet.github.io/event-lite/EventLite.html
  1580. * @example
  1581. * var EventLite = require("event-lite");
  1582. *
  1583. * function MyClass() {...} // your class
  1584. *
  1585. * EventLite.mixin(MyClass.prototype); // import event methods
  1586. *
  1587. * var obj = new MyClass();
  1588. * obj.on("foo", function() {...}); // add event listener
  1589. * obj.once("bar", function() {...}); // add one-time event listener
  1590. * obj.emit("foo"); // dispatch event
  1591. * obj.emit("bar"); // dispatch another event
  1592. * obj.off("foo"); // remove event listener
  1593. */
  1594.  
  1595. function EventLite() {
  1596. if (!(this instanceof EventLite)) return new EventLite();
  1597. }
  1598.  
  1599. const _module_ = {exports: {}};
  1600. (function(EventLite) {
  1601. // export the class for node.js
  1602. if ("undefined" !== typeof _module_) _module_.exports = EventLite;
  1603.  
  1604. // property name to hold listeners
  1605. var LISTENERS = "listeners";
  1606.  
  1607. // methods to export
  1608. var methods = {
  1609. on: on,
  1610. once: once,
  1611. off: off,
  1612. emit: emit
  1613. };
  1614.  
  1615. // mixin to self
  1616. mixin(EventLite.prototype);
  1617.  
  1618. // export mixin function
  1619. EventLite.mixin = mixin;
  1620.  
  1621. /**
  1622. * Import on(), once(), off() and emit() methods into target object.
  1623. *
  1624. * @function EventLite.mixin
  1625. * @param target {Prototype}
  1626. */
  1627.  
  1628. function mixin(target) {
  1629. for (var key in methods) {
  1630. target[key] = methods[key];
  1631. }
  1632. return target;
  1633. }
  1634.  
  1635. /**
  1636. * Add an event listener.
  1637. *
  1638. * @function EventLite.prototype.on
  1639. * @param type {string}
  1640. * @param func {Function}
  1641. * @returns {EventLite} Self for method chaining
  1642. */
  1643.  
  1644. function on(type, func) {
  1645. getListeners(this, type).push(func);
  1646. return this;
  1647. }
  1648.  
  1649. /**
  1650. * Add one-time event listener.
  1651. *
  1652. * @function EventLite.prototype.once
  1653. * @param type {string}
  1654. * @param func {Function}
  1655. * @returns {EventLite} Self for method chaining
  1656. */
  1657.  
  1658. function once(type, func) {
  1659. var that = this;
  1660. wrap.originalListener = func;
  1661. getListeners(that, type).push(wrap);
  1662. return that;
  1663.  
  1664. function wrap() {
  1665. off.call(that, type, wrap);
  1666. func.apply(this, arguments);
  1667. }
  1668. }
  1669.  
  1670. /**
  1671. * Remove an event listener.
  1672. *
  1673. * @function EventLite.prototype.off
  1674. * @param [type] {string}
  1675. * @param [func] {Function}
  1676. * @returns {EventLite} Self for method chaining
  1677. */
  1678.  
  1679. function off(type, func) {
  1680. var that = this;
  1681. var listners;
  1682. if (!arguments.length) {
  1683. delete that[LISTENERS];
  1684. } else if (!func) {
  1685. listners = that[LISTENERS];
  1686. if (listners) {
  1687. delete listners[type];
  1688. if (!Object.keys(listners).length) return off.call(that);
  1689. }
  1690. } else {
  1691. listners = getListeners(that, type, true);
  1692. if (listners) {
  1693. listners = listners.filter(ne);
  1694. if (!listners.length) return off.call(that, type);
  1695. that[LISTENERS][type] = listners;
  1696. }
  1697. }
  1698. return that;
  1699.  
  1700. function ne(test) {
  1701. return test !== func && test.originalListener !== func;
  1702. }
  1703. }
  1704.  
  1705. /**
  1706. * Dispatch (trigger) an event.
  1707. *
  1708. * @function EventLite.prototype.emit
  1709. * @param type {string}
  1710. * @param [value] {*}
  1711. * @returns {boolean} True when a listener received the event
  1712. */
  1713.  
  1714. function emit(type, value) {
  1715. var that = this;
  1716. var listeners = getListeners(that, type, true);
  1717. if (!listeners) return false;
  1718. var arglen = arguments.length;
  1719. if (arglen === 1) {
  1720. listeners.forEach(zeroarg);
  1721. } else if (arglen === 2) {
  1722. listeners.forEach(onearg);
  1723. } else {
  1724. var args = Array.prototype.slice.call(arguments, 1);
  1725. listeners.forEach(moreargs);
  1726. }
  1727. return !!listeners.length;
  1728.  
  1729. function zeroarg(func) {
  1730. func.call(that);
  1731. }
  1732.  
  1733. function onearg(func) {
  1734. func.call(that, value);
  1735. }
  1736.  
  1737. function moreargs(func) {
  1738. func.apply(that, args);
  1739. }
  1740. }
  1741.  
  1742. /**
  1743. * @ignore
  1744. */
  1745.  
  1746. function getListeners(that, type, readonly) {
  1747. if (readonly && !that[LISTENERS]) return;
  1748. var listeners = that[LISTENERS] || (that[LISTENERS] = {});
  1749. return listeners[type] || (listeners[type] = []);
  1750. }
  1751.  
  1752. })(EventLite);
  1753. var Events = _module_.exports;
  1754.  
  1755. /* eslint-env browser */
  1756.  
  1757. var INVALID_TAGS = {
  1758. a: true,
  1759. noscript: true,
  1760. option: true,
  1761. script: true,
  1762. style: true,
  1763. textarea: true,
  1764. svg: true,
  1765. canvas: true,
  1766. button: true,
  1767. select: true,
  1768. template: true,
  1769. meter: true,
  1770. progress: true,
  1771. math: true,
  1772. time: true
  1773. };
  1774.  
  1775. class Pos {
  1776. constructor(container, offset, i = 0) {
  1777. this.container = container;
  1778. this.offset = offset;
  1779. this.i = i;
  1780. }
  1781. add(change) {
  1782. var cont = this.container,
  1783. offset = this.offset;
  1784.  
  1785. this.i += change;
  1786. // If the container is #text.parentNode
  1787. if (cont.childNodes.length) {
  1788. cont = cont.childNodes[offset];
  1789. offset = 0;
  1790. }
  1791.  
  1792. // If the container is #text
  1793. while (cont) {
  1794. if (cont.nodeType == 3) {
  1795. if (!cont.LEN) {
  1796. cont.LEN = cont.nodeValue.length;
  1797. }
  1798. if (offset + change <= cont.LEN) {
  1799. this.container = cont;
  1800. this.offset = offset + change;
  1801. return;
  1802. }
  1803. change = offset + change - cont.LEN;
  1804. offset = 0;
  1805. }
  1806. cont = cont.nextSibling;
  1807. }
  1808. }
  1809. moveTo(offset) {
  1810. this.add(offset - this.i);
  1811. }
  1812. }
  1813.  
  1814. function cloneContents(range) {
  1815. if (range.startContainer == range.endContainer) {
  1816. return document.createTextNode(range.toString());
  1817. }
  1818. return range.cloneContents();
  1819. }
  1820.  
  1821. var DEFAULT_OPTIONS = {
  1822. maxRunTime: 100,
  1823. timeout: 10000,
  1824. newTab: true,
  1825. noOpener: true,
  1826. embedImage: true
  1827. };
  1828.  
  1829. class Linkifier extends Events {
  1830. constructor(root, options = {}) {
  1831. super();
  1832. if (!(root instanceof Node)) {
  1833. options = root;
  1834. root = options.root;
  1835. }
  1836. this.root = root;
  1837. this.options = Object.assign({}, DEFAULT_OPTIONS, options);
  1838. this.aborted = false;
  1839. }
  1840. start() {
  1841. var time = Date.now,
  1842. startTime = time(),
  1843. chunks = this.generateChunks();
  1844. var next = () => {
  1845. if (this.aborted) {
  1846. this.emit("error", new Error("Aborted"));
  1847. return;
  1848. }
  1849. var chunkStart = time(),
  1850. now;
  1851. do {
  1852. if (chunks.next().done) {
  1853. this.emit("complete", time() - startTime);
  1854. return;
  1855. }
  1856. } while ((now = time()) - chunkStart < this.options.maxRunTime);
  1857. if (now - startTime > this.options.timeout) {
  1858. this.emit("error", new Error(`max execution time exceeded: ${now - startTime}, on ${this.root}`));
  1859. return;
  1860. }
  1861. setTimeout(next);
  1862. };
  1863. setTimeout(next);
  1864. }
  1865. abort() {
  1866. this.aborted = true;
  1867. }
  1868. *generateRanges() {
  1869. var {validator} = this.options;
  1870. var filter = {
  1871. acceptNode: function(node) {
  1872. if (validator && !validator(node)) {
  1873. return NodeFilter.FILTER_REJECT;
  1874. }
  1875. if (INVALID_TAGS[node.localName]) {
  1876. return NodeFilter.FILTER_REJECT;
  1877. }
  1878. if (node.localName == "wbr") {
  1879. return NodeFilter.FILTER_ACCEPT;
  1880. }
  1881. if (node.nodeType == 3) {
  1882. return NodeFilter.FILTER_ACCEPT;
  1883. }
  1884. return NodeFilter.FILTER_SKIP;
  1885. }
  1886. };
  1887. // Generate linkified ranges.
  1888. var walker = document.createTreeWalker(
  1889. this.root,
  1890. NodeFilter.SHOW_TEXT + NodeFilter.SHOW_ELEMENT,
  1891. filter
  1892. ), start, end, current, range;
  1893.  
  1894. end = start = walker.nextNode();
  1895. if (!start) {
  1896. return;
  1897. }
  1898. range = document.createRange();
  1899. range.setStartBefore(start);
  1900. while ((current = walker.nextNode())) {
  1901. if (end.nextSibling == current) {
  1902. end = current;
  1903. continue;
  1904. }
  1905. range.setEndAfter(end);
  1906. yield range;
  1907.  
  1908. end = start = current;
  1909. range.setStartBefore(start);
  1910. }
  1911. range.setEndAfter(end);
  1912. yield range;
  1913. }
  1914. *generateChunks() {
  1915. var {matcher} = this.options;
  1916. for (var range of this.generateRanges()) {
  1917. var frag = null,
  1918. pos = null,
  1919. text = range.toString(),
  1920. textRange = null;
  1921. for (var result of matcher.match(text)) {
  1922. if (!frag) {
  1923. frag = document.createDocumentFragment();
  1924. pos = new Pos(range.startContainer, range.startOffset);
  1925. textRange = range.cloneRange();
  1926. }
  1927. // clone text
  1928. pos.moveTo(result.start);
  1929. textRange.setEnd(pos.container, pos.offset);
  1930. frag.appendChild(cloneContents(textRange));
  1931. // clone link
  1932. textRange.collapse();
  1933. pos.moveTo(result.end);
  1934. textRange.setEnd(pos.container, pos.offset);
  1935. var content = cloneContents(textRange),
  1936. link = this.buildLink(result, content);
  1937.  
  1938. textRange.collapse();
  1939.  
  1940. frag.appendChild(link);
  1941. this.emit("link", {link, range, result, content});
  1942. }
  1943. if (pos) {
  1944. pos.moveTo(text.length);
  1945. textRange.setEnd(pos.container, pos.offset);
  1946. frag.appendChild(cloneContents(textRange));
  1947. range.deleteContents();
  1948. range.insertNode(frag);
  1949. }
  1950. yield;
  1951. }
  1952. }
  1953. buildLink(result, content) {
  1954. var {newTab, embedImage, noOpener} = this.options;
  1955. var link = document.createElement("a");
  1956. link.href = result.url;
  1957. link.title = "Linkify Plus Plus";
  1958. link.className = "linkifyplus";
  1959. if (newTab) {
  1960. link.target = "_blank";
  1961. }
  1962. if (noOpener) {
  1963. link.rel = "noopener";
  1964. }
  1965. var child;
  1966. if (embedImage && /^[^?#]+\.(?:jpg|png|gif|jpeg|svg)(?:$|[?#])/i.test(result.url)) {
  1967. child = new Image;
  1968. child.src = result.url;
  1969. child.alt = result.text;
  1970. } else {
  1971. child = content;
  1972. }
  1973. link.appendChild(child);
  1974. return link;
  1975. }
  1976. }
  1977.  
  1978. function linkify(...args) {
  1979. return new Promise((resolve, reject) => {
  1980. var linkifier = new Linkifier(...args);
  1981. linkifier.on("error", reject);
  1982. linkifier.on("complete", resolve);
  1983. for (var key of Object.keys(linkifier.options)) {
  1984. if (key.startsWith("on")) {
  1985. linkifier.on(key.slice(2), linkifier.options[key]);
  1986. }
  1987. }
  1988. linkifier.start();
  1989. });
  1990. }
  1991.  
  1992. exports.UrlMatcher = UrlMatcher;
  1993. exports.Linkifier = Linkifier;
  1994. exports.INVALID_TAGS = INVALID_TAGS;
  1995. exports.linkify = linkify;
  1996.  
  1997. return exports;
  1998.  
  1999. }({}));
  2000. //# sourceMappingURL=linkify-plus-plus-core.js.map