linkify-plus-plus-core

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

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

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

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