linkify-plus-plus-core

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

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址