linkify-plus-plus-core

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

目前为 2021-02-11 提交的版本。查看 最新版本

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

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

QingJ © 2025

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