forked from MailOnline/VPAIDHTML5Client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add video provider tracking (MailOnline#23)
Add client config
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const CONFIG = { | ||
'telegraph': { | ||
selector: 'article[itemprop=articleBody]' | ||
}, | ||
'nigella': { | ||
selector: 'section.details' | ||
} | ||
} | ||
|
||
/** | ||
* Retrieve the current client based on the current URL we are in | ||
* @returns {*} | ||
*/ | ||
export function getClient() { | ||
const href = window.location.href; | ||
|
||
if (urlMatch('localhost')) return 'localhost'; | ||
if (urlMatch(['delta.sugges.tv/test/index', 'build.suggestv.io/test/index', 'build.suggestv.io/test/cjallen'])) return 'test'; | ||
if (urlMatch(['delta.sugges.tv/test', 'build.suggestv.io/test'])) return 'client-test'; | ||
if (urlMatch('telegraph.co.uk')) return 'telegraph'; | ||
if (urlMatch('londontheinside.com')) return 'londontheinside'; | ||
if (urlMatch('beautyandthedirt.com')) return 'beautyandthedirt'; | ||
if (urlMatch('bristol-sport.co.uk')) return 'bristolsport'; | ||
if (urlMatch('proactiveinvestors.co.uk')) return 'proactiveinvestors'; | ||
if (urlMatch('advfn.com')) return 'advfn'; | ||
if (urlMatch('hospitalitytrends.net')) return 'hospitalitytrends'; | ||
if (urlMatch('prospectmagazine.co.uk')) return 'prospectmagazine'; | ||
if (urlMatch('spectator.co.uk')) return 'spectator'; | ||
if (urlMatch('cityam.com')) return 'cityam'; | ||
if (urlMatch('hitc.com')) return 'hitc'; | ||
if (urlMatch('zmescience.com')) return 'sovrnus'; | ||
if (urlMatch(['livingly.com', 'independent.ie'])) return 'sovrnuk'; | ||
if (urlMatch('clickon.co')) return 'clickon'; | ||
if (urlMatch(['lbc.co.uk', 'classicfm.com', 'capitalfm.com', 'heart.co.uk', 'lbc.utest'])) return 'global-radio'; | ||
if (urlMatch('nigella.com')) return 'nigella'; | ||
|
||
function urlMatch(url) { | ||
return Array.isArray(url) | ||
? url.some(u => href.indexOf(u) !== -1) | ||
: href.indexOf(url) !== -1; | ||
} | ||
|
||
return 'unknown'; | ||
} | ||
|
||
/** | ||
* Returns a client specific page selector if there is one otherwise null | ||
* @param {elem} client | ||
*/ | ||
export function getPageSelector(client) { | ||
const config = CONFIG[client] || {}; | ||
const selector = config.selector; | ||
|
||
return selector ? document.querySelector(selector) : null; | ||
} |