1+ const CONFIG = {
2+ 'telegraph' : {
3+ selector : 'article[itemprop=articleBody]'
4+ } ,
5+ 'nigella' : {
6+ selector : 'section.details'
7+ }
8+ }
9+
10+ /**
11+ * Retrieve the current client based on the current URL we are in
12+ * @returns {* }
13+ */
14+ export function getClient ( ) {
15+ const href = window . location . href ;
16+
17+ if ( urlMatch ( 'localhost' ) ) return 'localhost' ;
18+ if ( urlMatch ( [ 'delta.sugges.tv/test/index' , 'build.suggestv.io/test/index' , 'build.suggestv.io/test/cjallen' ] ) ) return 'test' ;
19+ if ( urlMatch ( [ 'delta.sugges.tv/test' , 'build.suggestv.io/test' ] ) ) return 'client-test' ;
20+ if ( urlMatch ( 'telegraph.co.uk' ) ) return 'telegraph' ;
21+ if ( urlMatch ( 'londontheinside.com' ) ) return 'londontheinside' ;
22+ if ( urlMatch ( 'beautyandthedirt.com' ) ) return 'beautyandthedirt' ;
23+ if ( urlMatch ( 'bristol-sport.co.uk' ) ) return 'bristolsport' ;
24+ if ( urlMatch ( 'proactiveinvestors.co.uk' ) ) return 'proactiveinvestors' ;
25+ if ( urlMatch ( 'advfn.com' ) ) return 'advfn' ;
26+ if ( urlMatch ( 'hospitalitytrends.net' ) ) return 'hospitalitytrends' ;
27+ if ( urlMatch ( 'prospectmagazine.co.uk' ) ) return 'prospectmagazine' ;
28+ if ( urlMatch ( 'spectator.co.uk' ) ) return 'spectator' ;
29+ if ( urlMatch ( 'cityam.com' ) ) return 'cityam' ;
30+ if ( urlMatch ( 'hitc.com' ) ) return 'hitc' ;
31+ if ( urlMatch ( 'zmescience.com' ) ) return 'sovrnus' ;
32+ if ( urlMatch ( [ 'livingly.com' , 'independent.ie' ] ) ) return 'sovrnuk' ;
33+ if ( urlMatch ( 'clickon.co' ) ) return 'clickon' ;
34+ if ( urlMatch ( [ 'lbc.co.uk' , 'classicfm.com' , 'capitalfm.com' , 'heart.co.uk' , 'lbc.utest' ] ) ) return 'global-radio' ;
35+ if ( urlMatch ( 'nigella.com' ) ) return 'nigella' ;
36+
37+ function urlMatch ( url ) {
38+ return Array . isArray ( url )
39+ ? url . some ( u => href . indexOf ( u ) !== - 1 )
40+ : href . indexOf ( url ) !== - 1 ;
41+ }
42+
43+ return 'unknown' ;
44+ }
45+
46+ /**
47+ * Returns a client specific page selector if there is one otherwise null
48+ * @param {elem } client
49+ */
50+ export function getPageSelector ( client ) {
51+ const config = CONFIG [ client ] || { } ;
52+ const selector = config . selector ;
53+
54+ return selector ? document . querySelector ( selector ) : null ;
55+ }
0 commit comments