From 6dc809493c18f2159a982dcf71b6a2fc0e702d7e Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 5 Mar 2019 12:16:00 -0800 Subject: [PATCH] Add HTML5 video support param to bid requests (#3596) * Add HTML5 video support param to bid requests * Use const instead of var for consistency --- modules/sharethroughBidAdapter.js | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/modules/sharethroughBidAdapter.js b/modules/sharethroughBidAdapter.js index ee97ac739c4..ec97649df6d 100644 --- a/modules/sharethroughBidAdapter.js +++ b/modules/sharethroughBidAdapter.js @@ -12,12 +12,13 @@ export const sharethroughAdapterSpec = { buildRequests: (bidRequests, bidderRequest) => { return bidRequests.map(bid => { let query = { - bidId: bid.bidId, placement_key: bid.params.pkey, - hbVersion: '$prebid.version$', - strVersion: VERSION, + bidId: bid.bidId, + consent_required: false, + instant_play_capable: canAutoPlayHTML5Video(), hbSource: 'prebid', - consent_required: false + hbVersion: '$prebid.version$', + strVersion: VERSION }; if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.consentString) { @@ -148,4 +149,25 @@ function b64EncodeUnicode(str) { })); } +function canAutoPlayHTML5Video() { + const userAgent = navigator.userAgent; + if (!userAgent) return false; + + const isAndroid = /Android/i.test(userAgent); + const isiOS = /iPhone|iPad|iPod/i.test(userAgent); + const chromeVersion = parseInt((/Chrome\/([0-9]+)/.exec(userAgent) || [0, 0])[1]); + const chromeiOSVersion = parseInt((/CriOS\/([0-9]+)/.exec(userAgent) || [0, 0])[1]); + const safariVersion = parseInt((/Version\/([0-9]+)/.exec(userAgent) || [0, 0])[1]); + + if ( + (isAndroid && chromeVersion >= 53) || + (isiOS && (safariVersion >= 10 || chromeiOSVersion >= 53)) || + !(isAndroid || isiOS) + ) { + return true; + } else { + return false; + } +} + registerBidder(sharethroughAdapterSpec);