linkify-plus-plus-core

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

目前为 2024-02-13 提交的版本。查看 最新版本

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

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