From 57266490026124b1ed3e8a43fc99f5f553036a90 Mon Sep 17 00:00:00 2001 From: Alon Nachshon Date: Sun, 4 Dec 2022 22:18:13 +0200 Subject: [PATCH] update UA for haaretz, themarker --- src/js/background.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/js/background.js b/src/js/background.js index 0b22e6b..711e728 100755 --- a/src/js/background.js +++ b/src/js/background.js @@ -182,7 +182,9 @@ const useGoogleBotSites = [ ]; // Override User-Agent with Bingbot -const useBingBot = [ +const useBingBot = []; + +const useGoogleAdsBotMobile = [ 'haaretz.co.il', 'haaretz.com', 'themarker.com' @@ -257,6 +259,7 @@ const userAgentDesktop = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.go const userAgentMobile = 'Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible ; Googlebot/2.1 ; +http://www.google.com/bot.html)'; const userAgentDesktopBingBot = 'Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)'; const userAgentMobileBingBot = 'Chrome/80.0.3987.92 Mobile Safari/537.36 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)'; +const userAgentGoogleAdsBotMobile = 'Mozilla/5.0 (Linux; Android 5.0; SM-G920A) AppleWebKit (KHTML, like Gecko) Chrome Mobile Safari (compatible; AdsBot-Google-Mobile; +http://www.google.com/mobile/adsbot.html)'; let enabledSites = []; @@ -445,6 +448,15 @@ extensionApi.webRequest.onBeforeSendHeaders.addListener(function (details) { }); } + // override User-Agent to use Google AdsBot Mobile Web + if (matchUrlDomain(useGoogleAdsBotMobile, details.url)) { + requestHeaders.push({ + name: 'User-Agent', + value: userAgentGoogleAdsBotMobile + }); + } + + // remove cookies before page load const enabledCookies = allowCookies.some(function (site) { return matchUrlDomain(site, details.url);