
Security News
Security Community Slams MIT-linked Report Claiming AI Powers 80% of Ransomware
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.
fresh8-js-module
Advanced tools
Dynamically inject Fresh8 ads into your website or app.
This project is auto compiled from ES2015 to ES5 by Babel, if you'd like to use the ES2015 code directly you can require it by doing the following:
import Fresh8 from 'fresh8/src';
If you want use this in an React app you can use our prebuilt component here.
npm install fresh8-js-module --savevar Fresh8 = require('fresh8-js-module').default;npm install fresh8-js-module --saveimport Fresh8 from 'fresh8-js-module';You can find a minified script that defines the Fresh8 object globally in dist/browser.js.
During your on-boarding process you'll receive a unique set of ID's for the publications, websites and applications you want to display ads on. We refer to these as "installation ID's", each ID is unique to the publication and allows you to control the ads via our console. Along with these you'll also receive a set of slot ID's that determine what sizes of ad creative will be served to your publications, you can see a list of available slots here.
The Fresh8 class takes a number of different configurations as an Object, the following lists each available option and what it does:
instIDThe installation ID for the publication you want to create ads for.
| Key | Value | Required | Default | 
|---|---|---|---|
| instID | String | Y | undefined | 
shouldBreakOutThis controls if the ads should try and break out of iframe's and append to the most top window. It does this by looping over all the window.parent properties until there are no more or an error is throw because of a browser security exception. This is useful if you want to inject the ads via a third party ad manger that uses iframe's but still want the ads to be displayed in the correct element outside of the iframe.
| Key | Value | Required | Default | 
|---|---|---|---|
| shouldBreakOut | Boolean | N | false | 
inAppThis defines if the ads are being used inside of a web view in Android/iOS.
| Key | Value | Required | Default | 
|---|---|---|---|
| inApp | Boolean | N | false | 
listenOnPushStateMonkey patches the window.history.pushState function to emit an event, on receipt of this event the ads will reload. Useful for single page apps that don't reload the page on navigation.
| Key | Value | Required | Default | 
|---|---|---|---|
| listenOnPushState | Boolean | N | false | 
remove()Removes any event listeners added by the class and destroys any ads on the page.
destroyAllAds()Removes all ads from the page.
reloadAllAds()Refreshes all the currently active ads on the page and returns promise that resolves with an array of ads.
requestAd(config)requestAd method takes a number of different configurations as an Object and returns a promise. The following lists each available option and what it does:
slotIDThe slot size that you'd like to request an for.
| Name | Type | Required | Default | 
|---|---|---|---|
| slotID | String | Y | undefined | 
appendPointThis is a query selector string that defines where the ad will be appended on the page.
| Name | Type | Required | Default | 
|---|---|---|---|
| appendPoint | String | Y | undefined | 
urlThis allows you to override the default URL that the classification engine uses when determining sports, teams and players are in your content. By default this will use the window.location, unless canonical link tag is found on the page.
| Key | Value | Required | Default | 
|---|---|---|---|
| url | String | X | window.locationor<link rel="canonical"> | 
viewView is used for targeting and identifying specific views/pages in the Fresh8 Console. For example you might want to just do a specific set of ads on the football view pages.
| Key | Value | Required | Default | 
|---|---|---|---|
| view | String | X | '' | 
clickTrackingRedirectAn optional redirection URL used for tracking .E.G a Google DFP click macro %%CLICK_URL_ESC_ESC%%.
| Name | Type | Required | Default | 
|---|---|---|---|
| clickTrackingRedirect | String | X | '' | 
sportAn optional sport value used for targeting overrides, for example cricket.
Note: Sport is required if competitors or competitions are added as part of the config.
| Key | Value | Required | Default | 
|---|---|---|---|
| sport | String | X/Y | '' | 
matchIDAn optional Opta ID used for targeting overrides. Note: Opta ID's are only supported for football currently.
| Key | Value | Required | Default | 
|---|---|---|---|
| matchID | String | X | '' | 
competitorIDsOptional Opta ID's used for targeting overrides. Note: Opta ID's are only supported for football currently.
| Key | Value | Required | Default | 
|---|---|---|---|
| competitorIDs | Array | X | [] | 
competitorsAn optional competitors array used for targeting overrides, for example ['Manchester United', 'Southampton'].
| Key | Value | Required | Default | 
|---|---|---|---|
| competitors | Array | X | [] | 
competitionIDsOptional Opta ID's used for targeting overrides. Note: Opta ID's are only supported for football currently.
| Key | Value | Required | Default | 
|---|---|---|---|
| competitionIDs | Array | X | [] | 
competitionsAn optional competitions array used for targeting overrides, for example ['Premier League'].
| Key | Value | Required | Default | 
|---|---|---|---|
| competitions | Array | X | [] | 
linkSameWindowAn optional flag to override link behaviour, making all links open in the same window.
| Key | Value | Required | Default | 
|---|---|---|---|
| linkSameWindow | Boolean | X | false | 
brandAn optional parameter to pass through the brand identify, sometimes required if you have more than one brand per publication or ad tag. Fresh8 will supply you with this value if needed.
| Key | Value | Required | Default | 
|---|---|---|---|
| brand | String | X | undefined | 
An instantiated ad class is resolved from the requestAd method on success
reloadReloads destroys the current ad in place then requests new data from the ad serving API. Using that data it creates a new ad in it's place.
destroyRemoves the ad from the DOM and cleans up any event listens and scripts added.
This is an example of the simplest configuration possible:
var config = { instID: '40410' };
var fresh8 = new Fresh8(config);
fresh8.requestAd({ slotID: 'f8-001', appendPoint: 'body' });
A more complex config might look like:
var config = { instID: '40410', inApp: false, shouldBreakOut: false, listenOnPushState: false };
var fresh8 = new Fresh8(config);
fresh8
  .requestAd({
    slotID: 'f8-001',
    url: 'http://fresh8gaming.com',
    appendPoint: 'body',
    view: 'home-page',
    clickTrackingRedirect: 'http://dfp.com?r=',
    sport: 'football',
    competitors: ['Manchester United', 'Southampton'],
    competitions: ['Premier League'],
    listenOnPushState: true
  })
  .then(ad => console.log('Ad loaded', ad))
  .catch(reason => console.error(reason));
npm testnpm run coverage && npm run covcoverage: Runs the isparta code coverage on the moduletest: Runs the unit testsbuild: Compiles the code to ES5 in the dist folderdev: Compiles the code to ES5 and watches for changescov Opens the code coverage folderFAQs
Dynamically inject Fresh8 ads into your website or app.
We found that fresh8-js-module demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 16 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.

Research
/Security News
Socket researchers found 10 typosquatted npm packages that auto-run on install, show fake CAPTCHAs, fingerprint by IP, and deploy a credential stealer.