Skip to content

Instantly share code, notes, and snippets.

@x3388638
Last active May 22, 2019 09:11
Show Gist options
  • Save x3388638/c38e479c0aa5468512f8da2259dfdeed to your computer and use it in GitHub Desktop.
Save x3388638/c38e479c0aa5468512f8da2259dfdeed to your computer and use it in GitHub Desktop.
YUI().use('node-base', function(Y) {
Y.Global.on('ymediaReady', function(data) {
YMedia = data.e;
YMedia.applyConfig({
"groups": {
"td-applet-mega-header": {
"base": "https://s.yimg.com/os/mit/td/td-applet-mega-header-1.0.888/",
"root": "os/mit/td/td-applet-mega-header-1.0.888/",
"combine": false,
"filter": "min",
"comboBase": "https://s.yimg.com/zz/combo?",
"comboSep": "&"
}
}
});
window.Af = window.Af || {};
window.Af.bootstrap = window.Af.bootstrap || {};
window.Af.bootstrap["p_30345894"] = {
"applet_type": "td-applet-mega-header",
"views": {
"main": {
"yui_module": "td-applet-mega-header-mainview",
"yui_class": "TD.Applet.MegaHeaderMainView",
"config": {
"accountSwitchData": {
"enabled": 1,
"jsonpUrl": "https://jsapi.login.yahoo.com/w/device_users?.crumb=%2FtpaDCw8w4m",
"manageUrl": "https://login.yahoo.com/manage_account?.crumb=%2FtpaDCw8w4m&.done=https%3A%2F%2Fwww.yahoo.com",
"signoutUrl": "https://login.yahoo.com/config/login/?logout_all=1&.crumb=%2FtpaDCw8w4m&.direct=2&.done=https%3A%2F%2Fwww.yahoo.com",
"switchUrl": "https://login.yahoo.com/d?.crumb=%2FtpaDCw8w4m&as=1&login={alias}&.done=https%3A%2F%2Fwww.yahoo.com",
"main_user": {
"doneUrl": "https%3A%2F%2Fwww.yahoo.com",
"alias": "d5584392",
"fn": "YY"
},
"welcomeMsgTimeout": 1000,
"errorTimeout": 10000,
"profileUrl": "https://edit.yahoo.com/config/eval_profile",
"showWelcome": false,
"alphatar": {
"enabled": true,
"urlPath": "https://s.yimg.com/rz/uh/alphatars/",
"imgType": ".png"
},
"accountLimit": 2,
"useAvatar": true,
"userIntentMgmt": false
},
"alphatar": {
"enabled": true,
"urlPath": "https://s.yimg.com/rz/uh/alphatars/",
"imgType": ".png"
},
"avatar": {
"serverCall": false,
"ucs": {
"protocol": "https",
"host": "ucs.query.yahoo.com",
"path": "/v1/console/yql",
"query": {
"format": "json",
"_maxage": 900
}
},
"cp": {
"protocol": "https",
"host": "ha-sg3.api.udb.yahoo.com:4443",
"path": "/v3/users/yahoo/credential",
"query": {
"fields": "guid,name,profileImages"
},
"port": "4443",
"url": "https://ha-sg3.api.udb.yahoo.com:4443/v3/users/yahoo/credential?fields=guid%2Cname%2CprofileImages"
},
"imgsize": 48,
"timeout": 250,
"version": "cp"
},
"banner": false,
"bottomBar": true,
"bucket": "903",
"hasDialpad": false,
"hasHelpMenu": false,
"extensionHelper": {
"enabled": true,
"extensions": {
"homepage": {
"chrome": {
"url": "https://chrome.google.com/webstore/detail/jdanfkhnfpagoijgfmklhgakdicpnfil",
"minVersion": 31,
"maxVersion": 0,
"os": ["win", "mac"]
},
"firefox": {
"url": "https://addons.mozilla.org/en-US/firefox/addon/yahoo-homepage/",
"xpi": "https://addons.mozilla.org/firefox/downloads/latest/yahoo-homepage/addon-705134-latest.xpi",
"minVersion": 38,
"maxVersion": 0,
"os": ["win", "mac"]
},
"markupFlagClassName": "yahoo_hp_set_ext_installed",
"markupFlagSelector": "body"
},
"partnerDisable": false
},
"hashTag": "extInstall?partner=uk"
},
"firstName": "YY",
"followable": {
"enabled": false,
"uri": "/_td_api"
},
"formHoverState": false,
"hasExtensionPromo": {
"intlSelector": {
"enabled": true,
"link": "https://uk.yahoo.com/everything/world",
"intl": "uk",
"slk": "country",
"elm": "country"
},
"promos": {
"linkPromo": {
"enabled": true,
"eyeBrowPromoBgUrl": "",
"icon": "",
"link": "https://chrome.google.com/webstore/detail/jdanfkhnfpagoijgfmklhgakdicpnfil",
"label": "Make Yahoo your homepage",
"localizedLabel": false,
"linkStyles": "font-weight: bold; margin-right: 56px;",
"bgStyles": "",
"showChevron": false,
"sec": "hd",
"elm": "hpset"
},
"extensionPromo": {
"enabled": false,
"label": "Click here to set Yahoo as your home page"
},
"subscriptionPromo": {
"enabled": false,
"icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAAAXNSR0IArs4c6QAAAp5JREFUSA21lT1oFEEUx/9vb8mRiCAiAcEiaAKaiyDcXfwgQhoLjQQFRVCwsTBYaWGhVRoLBbFIIWKlRUoVJQl2IgjmjI25U0kiUaIigmhE8EJy93x7SDI7O7M7G83BwXv/9/Hbmdl5C/ynH5eL57hc+Cb/Cy4tPZekpByuFPqB+hCYN0puT1J+EP9nMFeKu1DnYfDfXsRzaw7m1/nNAn0koHUrMJpZse3WqlfMc3ubUaOHAG8Jt19DMDMT5hfvCrQQhgae77RiP1rooJQLVyTrWDSTltCZfR/Vo0rqrZbrclraXIq2EoX4A9GTJWNME1OBudK9X7b3ttZDdd+pTpztDOap4lZw7Z5cm6aYhk7nG9Q7gXm2dwMW6iMC3RQDlc3wZmPjSpAU22gy9/oo/xqVrgeMCSFRXi7ipyC6j6bMA+oY/xgKK04yeLJwU6ADSo2bSbI/wDOQd5xyL77oRbFbLW/w+VVBAwojQPfIDD+lQwPfCpZx2CfV101FqTTOlE359gFSw624BzM1i2hE16ir9DiiJzSOnIupgV2jUeQOmwdNLLg5e0hG0ZDkzNubWyNv0cIniQbrtozkt/pzvgXfvRPykR+Qf7etkaL/gJ/ZTTtKU4oWMRPBagVP5l+Jv1PVwjbV5Pr02c5VzbW+1WrSsk3UtmybDMJFF2hQ6gzmmX2tstXrTbyGRrhDXRM3rHEt4AzG78V2rVZ1nyPbelYVkmx3MHibpdkneN5R6hhbsMSNsn2A6OnE7Y3pq+pEVfjeEdpeSn3n3VfMiK6Y+IxAJ9RncbXdwYTwGZN3lXIvh11Bep47GKEVjyDXd1lvlsZ3GiA8fTCL6tdqozHhDbL+HvnI/0wD0nOdwEGRfJvH5B63IeP3U+f4tN4orf8HANKx7IxUMdEAAAAASUVORK5CYII=",
"label": "Get breaking news notifications"
}
},
"top": {
"links": [{
"iconClasses": "Icon-Fp2 IconHome",
"property": "home",
"title": "Home",
"url": "https://uk.yahoo.com/",
"position": 1
}, {
"property": "mail",
"title": "Mail",
"url": "https://mail.yahoo.com/?.intl=uk&.lang=en-GB&.partner=none&.src=fp",
"position": 2
}, {
"property": "news",
"title": "News",
"url": "https://uk.news.yahoo.com/",
"position": 3
}, {
"property": "sports",
"title": "Sports",
"url": "https://uk.sports.yahoo.com/",
"position": 4
}, {
"property": "finance",
"title": "Finance",
"url": "https://uk.finance.yahoo.com/",
"position": 5
}, {
"property": "celebrity",
"title": "Celebrity",
"url": "https://uk.celebrity.yahoo.com/",
"position": 6
}, {
"property": "style",
"title": "Style",
"url": "https://uk.style.yahoo.com/",
"position": 7
}, {
"property": "weather",
"title": "Weather",
"url": "https://uk.news.yahoo.com/weather/",
"position": 8
}, {
"property": "answers",
"title": "Answers",
"url": "https://uk.answers.yahoo.com/",
"position": 9
}, {
"property": "mobile",
"title": "Mobile",
"url": "https://uk.mobile.yahoo.com/",
"position": 10
}, {
"property": "more",
"title": "More",
"type": "menu",
"url": "https://uk.yahoo.com/everything",
"links": [{
"property": "messenger",
"title": "Messenger",
"url": "https://uk.messenger.yahoo.com/",
"position": 12
}, {
"property": "movies",
"title": "Movies",
"url": "https://uk.movies.yahoo.com/",
"position": 13
}, {
"property": "groups",
"title": "Groups",
"url": "https://uk.groups.yahoo.com/",
"position": 14
}],
"position": 11
}]
},
"bottom": {
"links": [{
"iconClasses": "Icon-Fp2 IconMail",
"property": "mail",
"title": "Mail",
"url": "https://mail.yahoo.com/?.intl=uk&.lang=en-GB&.partner=none&.src=fp"
}, {
"property": "news",
"title": "News",
"url": "https://uk.news.yahoo.com/"
}, {
"property": "sports",
"title": "Sports",
"url": "https://uk.sports.yahoo.com/"
}, {
"property": "finance",
"title": "Finance",
"url": "https://uk.finance.yahoo.com/"
}, {
"property": "celebrity",
"title": "Celebrity",
"url": "https://uk.celebrity.yahoo.com/"
}, {
"property": "style",
"title": "Style",
"url": "https://uk.style.yahoo.com/"
}, {
"property": "movies",
"title": "Movies",
"url": "https://uk.movies.yahoo.com/"
}, {
"property": "more",
"title": "More...",
"url": "https://uk.yahoo.com/everything"
}]
},
"dialpad": {
"links": [{
"iconClasses": "Bgi($dialPadPanelBgImg) Bgp($dialPadHomePos) ua-ie7_Bgi($dialPadNonRetinaPanelBgImg) ua-ie8_Bgi($dialPadNonRetinaPanelBgImg)",
"i13n": "sec:hd;slk:home;subsec:nav;",
"property": "yahoo",
"title": "Yahoo",
"url": "https://www.yahoo.com/"
}, {
"iconClasses": "Bgi($dialPadPanelBgImg) Bgp($dialPadMailPos) ua-ie7_Bgi($dialPadNonRetinaPanelBgImg) ua-ie8_Bgi($dialPadNonRetinaPanelBgImg)",
"i13n": "sec:hd;slk:mail;subsec:nav;",
"property": "mail",
"title": "Mail",
"url": "https://mail.yahoo.com/"
}, {
"iconClasses": "Bgi($dialPadPanelBgImg) Bgp($dialPadNewsPos) ua-ie7_Bgi($dialPadNonRetinaPanelBgImg) ua-ie8_Bgi($dialPadNonRetinaPanelBgImg)",
"i13n": "sec:hd;slk:news;subsec:nav;",
"property": "news",
"title": "News",
"url": "https://news.yahoo.com/"
}, {
"iconClasses": "Bgi($dialPadPanelBgImg) Bgp($dialPadFinancePos) ua-ie7_Bgi($dialPadNonRetinaPanelBgImg) ua-ie8_Bgi($dialPadNonRetinaPanelBgImg)",
"i13n": "sec:hd;slk:finance;subsec:nav;",
"property": "finance",
"title": "Finance",
"url": "https://finance.yahoo.com/"
}, {
"iconClasses": "Bgi($dialPadPanelBgImg) Bgp($dialPadSportsPos) ua-ie7_Bgi($dialPadNonRetinaPanelBgImg) ua-ie8_Bgi($dialPadNonRetinaPanelBgImg)",
"i13n": "sec:hd;slk:sports;subsec:nav;",
"property": "sports",
"title": "Sports",
"url": "https://sports.yahoo.com/"
}, {
"iconClasses": "Bgi($dialPadPanelBgImg) Bgp($dialpadFantastyPos) ua-ie7_Bgi($dialPadNonRetinaPanelBgImg) ua-ie8_Bgi($dialPadNonRetinaPanelBgImg)",
"i13n": "sec:hd;slk:fantasy;subsec:nav;",
"property": "fantasy",
"title": "Fantasy",
"url": "https://football.fantasysports.yahoo.com/"
}, {
"iconClasses": "Bgi($dialPadPanelBgImg) Bgp($dialPadPoliticsPos) ua-ie7_Bgi($dialPadNonRetinaPanelBgImg) ua-ie8_Bgi($dialPadNonRetinaPanelBgImg)",
"i13n": "sec:hd;slk:politics;subsec:nav;",
"property": "politics",
"title": "Politics",
"url": "https://news.yahoo.com/politics/"
}, {
"iconClasses": "Bgi($dialPadPanelBgImg) Bgp($dialPadCelebrityPos) ua-ie7_Bgi($dialPadNonRetinaPanelBgImg) ua-ie8_Bgi($dialPadNonRetinaPanelBgImg)",
"i13n": "sec:hd;slk:celebrity;subsec:nav;",
"property": "celebrity",
"title": "Celebrity",
"url": "https://www.yahoo.com/entertainment/celebrity/"
}, {
"iconClasses": "Bgi($dialPadPanelBgImg) Bgp($dialPadViewPos) ua-ie7_Bgi($dialPadNonRetinaPanelBgImg) ua-ie8_Bgi($dialPadNonRetinaPanelBgImg)",
"i13n": "sec:hd;slk:view;subsec:nav;",
"property": "view",
"title": "View",
"url": "https://view.yahoo.com/"
}],
"footer": {
"i13n": "sec:hd;subsec:nav;slk:see more;",
"title": "SEE MORE",
"url": "https://www.yahoo.com/everything/"
}
},
"selectedPromo": "linkPromo"
},
"hasMail": true,
"hasMailPreview": true,
"hasNotificationCenterLink": false,
"hasNotifications": true,
"hasProfile": true,
"isFallback": false,
"isRecognizedUser": false,
"loginUrl": "https://login.yahoo.com/config/login?.src=fpctx&.intl=uk&.lang=en-GB&.done=https%3A%2F%2Fuk.yahoo.com",
"logoutUrl": "https://login.yahoo.com/config/login?logout=1&.direct=2&.src=fpctx&.intl=uk&.lang=en-GB&.done=https%3A%2F%2Fuk.yahoo.com",
"mail": {
"compose": {
"url": "https://mail.yahoo.com/mrd/mail/any/compose"
},
"count": {
"api": {
"protocol": "https",
"host": "apis.mail.yahoo.com",
"path": "/ws/v3/batch",
"query": {
"appid": "YahooFrontPage",
"q": ""
},
"requestQuery": "{\"responseType\":\"json\",\"requests\":[{\"id\":\"GetMailboxId\",\"uri\":\"/ws/v3/mailboxes/\",\"method\":\"GET\",\"filters\":{\"iterator\":\"$..mailboxes[?(@.isPrimary==true)]\",\"select\":{\"mailboxId\":\"$..id\"}},\"suppressResponse\":true,\"requests\":[{\"id\":\"ListDecos\",\"uri\":\"/ws/v3/mailboxes/@.id==$(mailboxId)/decos\",\"method\":\"GET\"}]}]}",
"url": "https://apis.mail.yahoo.com/ws/v3/batch?appid=YahooFrontPage&q="
},
"refreshInterval": 120,
"maxCountDisplay": 99
},
"preview": {
"prefetch": false,
"api": {
"protocol": "https",
"host": "apis.mail.yahoo.com",
"path": "/ws/v3/batch",
"query": {
"appid": "YahooFrontPage",
"q": ""
},
"requestQuery": "{\"responseType\":\"json\",\"requests\":[{\"id\":\"GetMailboxId\",\"uri\":\"/ws/v3/mailboxes/\",\"method\":\"GET\",\"filters\":{\"select\":{\"mailboxId\":\"$..mailboxes[?(@.isPrimary==true)].id\"}},\"suppressResponse\":true,\"requests\":[{\"id\":\"ListMessages\",\"uri\":\"/ws/v3/mailboxes/@.id==$(mailboxId)/messages/@.select==q?q=count%3A6+offset%3A0+folderType%3AINBOX+-sort%3Adate\",\"method\":\"GET\"}]}]}",
"url": "https://apis.mail.yahoo.com/ws/v3/batch?appid=YahooFrontPage&q="
},
"earnyUpsellPosition": "",
"earnyUpsellImg": "",
"urls": {
"earnyOauth": "https://mail.yahoo.com/d/earnyOauth",
"message": "https://mail.yahoo.com/mrd/mail/any/message?imid="
}
},
"url": "https://mail.yahoo.com/?.intl=uk&.lang=en-GB&.partner=none&.src=fp",
"useCors": true,
"useYqlApi": 0
},
"mailBeacon": 1,
"miniheader": true,
"miniheaderHeight": 0,
"miniheaderYPos": 0,
"notifications": {
"polling": true,
"pollingInterval": 300,
"notificationClient": {
"badge": {
"hideClass": "D(n)"
},
"enabled": true,
"historyServicePath": "/_td_api/resource/notificationHistory",
"panel": {
"notificationCenterPath": "/notifications"
},
"promos": {
"enableNotifOnboard": true
}
},
"subscriptionHelper": {
"enabled": true,
"enableChurnCheck": true,
"enableSubsResyncIfError": true,
"churnCheckBackoff": 604800,
"confirmationNotification": {
"body": "We will send you notifications about latest breaking news. Change settings anytime under the bell on Yahoo.com",
"enabled": true,
"icon": "https://s.yimg.com/rz/uh/notifications/default-notif-img.png",
"title": "Welcome!"
},
"overlay": {
"default": {
"backgroundColor": "rgba(236, 236, 236, .95)",
"imageHeight": 227,
"imageUrl": "https://s.yimg.com/rz/uh/notifications/inst-push-perm-6.png",
"imageWidth": 541,
"overlayId": "permission-instructions",
"xOffset": 335,
"yOffset": 83
},
"denied": {
"backgroundColor": "rgba(236, 236, 236, .95)",
"imageHeight": 326,
"imageUrl": "https://s.yimg.com/rz/uh/notifications/inst-unblock-push-perm.png",
"imageWidth": 490,
"overlayId": "unblock-instructions",
"xOffset": 100,
"yOffset": 2
}
},
"resubscribeOnChurn": true,
"serviceWorkerUrl": "/service-worker.js",
"spaceId": 1197806515,
"subscriptionService": {
"host": null,
"path": "/_td_api",
"protocol": null
},
"supportedBrowsers": {
"chrome": {
"maxVersion": 0,
"minVersion": 54,
"os": ["win", "mac"],
"useServiceWorker": true
}
}
},
"autoInitSubscription": 0,
"pushPromo": 0
},
"search": {
"action": "https://uk.search.yahoo.com/search",
"appendFrToTypeQuery": false,
"assistYlc": ";_ylc=X3oDMTFiaHBhMnJmBF9TAzIwMjM1MzgwNzUEaXRjAzEEc2VjA3NyY2hfcWEEc2xrA3NyY2hhc3Q-",
"fr2Code": "",
"ylc": ";_ylc=X3oDMTFiN25laTRvBF9TAzIwMjM1MzgwNzUEaXRjAzEEc2VjA3NyY2hfcWEEc2xrA3NyY2h3ZWI-",
"searchTermQueryKey": "p",
"queries": [{
"name": "fr",
"value": "yfp-t"
}, {
"name": "fp",
"value": "1"
}, {
"name": "toggle",
"value": "1"
}, {
"name": "cop",
"value": "mss"
}, {
"name": "ei",
"value": "UTF-8"
}],
"autocomplete": {
"additionalParams": {
"appid": "fp"
},
"ghostEnabled": false,
"host": "https://uk.search.yahoo.com/sugg/gossip/gossip-uk-ura/",
"crumbKey": "gossip",
"theme": {
"highlight": {
"color": "black",
"background": "#c6d7ff"
}
},
"plugin": {
"minQueryLength": 1,
"resultHighlighter": "phraseMatch"
}
},
"i13nModel": {
"elm": "btn",
"elmt": "srch",
"itc": "0",
"rspns": "nav",
"sec": "srch",
"slk": "srchweb",
"tar": "uk.search.yahoo.com",
"tar_uri": "/search",
"t1": "a1",
"t2": "srch"
},
"i13nSuggestion": {
"cpos": "cposV",
"elm": "itm",
"elmt": "srch",
"itc": "0",
"rspns": "nav",
"sec": "srch",
"slk": "srchast",
"tar": "uk.search.yahoo.com",
"t1": "a1",
"t2": "srch",
"t3": "tray",
"t9": "t9Val"
},
"i13nModelString": "elm:btn;elmt:srch;itc:0;rspns:nav;sec:srch;slk:srchweb;tar:uk.search.yahoo.com;tar_uri:/search;t1:a1;t2:srch",
"i13nSuggestionString": "cpos:cposV;elm:itm;elmt:srch;itc:0;rspns:nav;sec:srch;slk:srchast;tar:uk.search.yahoo.com;t1:a1;t2:srch;t3:tray;t9:t9Val"
},
"searchAssistJS": true,
"searchBtnIcon": true,
"searchFormGlow": true,
"topBar": true,
"useAvatar": true,
"userAgent": {
"browserName": "chrome",
"browserVersion": 74,
"browserVendor": "google",
"os": "mac"
}
}
},
"avatar": {
"yui_module": "mega-header-plugin-avatar-cp",
"yui_class": "Y.TD.megaHeaderAvatarCP"
},
"mail": {
"yui_module": "mega-header-plugin-mail",
"yui_class": "Y.TD.megaHeaderMail"
}
},
"templates": {
"main": {
"yui_module": "td-applet-mega-header-templates-main",
"template_name": "td-applet-mega-header-templates-main",
"lazy_load": true
},
"mailpreview": {
"yui_module": "td-applet-mega-header-templates-mailpreview",
"template_name": "td-applet-mega-header-templates-mailpreview"
},
"accountSwitchPanel": {
"yui_module": "td-applet-mega-header-templates-accountSwitchPanel",
"template_name": "td-applet-mega-header-templates-accountSwitchPanel"
},
"profile": {
"yui_module": "td-applet-mega-header-templates-profile",
"template_name": "td-applet-mega-header-templates-profile"
}
},
"i18n": {
"ACCOUNT_INFO": "Account info",
"ACCOUNT_SWITCH_WELCOME_1": "Easily switch between multiple Yahoo accounts using the new",
"ACCOUNT_SWITCH_WELCOME_2": "Click on ‘Add account’ below to get started.",
"ACCOUNT_SWITCH_COOKIE_ERR": "It looks as though you’ve switched accounts. Refresh the browser to view your personalised page.",
"ACCOUNT_SWITCH_CRUMB_ERR": "Your account data may be out of sync.<br>Refresh the page to see your accounts.",
"ACCOUNT_SWITCH_ACCOUNT_MANAGER": "Account manager",
"ADD_ACCOUNT": "Add account",
"ADD_MANAGE_ACCOUNT": "Add or manage accounts",
"BANNER_PROMO_TITLE": "Make Yahoo your homepage",
"BANNER_PROMO_DESC": "Discover something new every day from News, Sport, Finance, Entertainment and more!",
"BANNER_PROMO_CLOSE": "No, thanks",
"BANNER_PROMO_ADD": "Get",
"CLEAR_SEARCH": "Clear search query",
"CLOSE": "Close",
"COMPOSE": "Compose",
"CORPMAIL": "Corp Mail",
"DEVELOPING_NOW": "Developing now",
"DIALPAD_FEATURE_CUE_MSG": "Get to <strong>News, Sport and Finance</strong> here",
"EARNY_UPSELL_IMG_ALT": "Automatic refunds",
"EARNY_UPSELL_HEADING": "You may have overpaid",
"EARNY_UPSELL_DESC": "Use your receipts to get money back",
"EARNY_UPSELL_BUTTON_TITLE": "Show me how much I could save",
"ENTER_KEY": "Enter",
"FOLLOW": "Follow",
"FOLLOWING": "Following",
"FOR": "For",
"FROM": "From",
"GO_TO_MAIL": "Go to Mail",
"HAVE_NO_NEW_MESSAGES": "You have no new messages.",
"HOME": "Home",
"HELP": "Help",
"IEINSTALLER_SET_YAHOO_AS_HP": "Set Yahoo as your homepage",
"IEINSTALLER_MODAL_TEXT": "Click \"<strong>Run</strong>\" and you'll never miss a thing with Yahoo as your default homepage and new tab page across all browsers on your device.",
"IEINSTALLER_PRIVACY_TERMS": "<a href='{termsUrl}' target='_blank'>Yahoo Terms</a> and <a href='{privacyUrl}' target='_blank'>Privacy Policy</a> apply",
"LOADING_MAIL": "Loading email preview",
"LOADING_UPDATES": "Loading updates",
"MAIL": "Mail",
"MENU": "Menu",
"NAVIGATION": "Navigation",
"NEW": "New",
"NEW_MESSAGE": "new message.",
"NEW_MESSAGES": "new messages.",
"NOTIFICATIONS": "Notifications",
"NOTIFICATION_CENTER_NAV_MSG": "View all {newCount} notifications",
"NO_NEW_NOTIFICATIONS": "You have no new notifications.",
"NOTIFY_ME": "Notify me",
"NOTIF_PANEL_PROMO_TEXT": "Get notifications for your favourite topics",
"NOTIF_CONFIRMATION_TEXT": "We will send you notifications about the latest breaking news. Change settings at any time under the bell on {hostName}",
"NOTIF_CONFIRMATION_TITLE": "Welcome!",
"PLEASE_CHECK_BACK_LATER": "Please check back later.",
"PROFILE": "Profile",
"PUSH_NOTIF_DISABLED": "You are not receiving browser alerts",
"PUSH_NOTIF_ENABLED": "You are receiving browser alerts",
"REL_DAYS": "{0}d",
"REL_DAYS_AGO": "{0} days ago",
"REL_HOURS": "{0}h",
"REL_HOURS_AGO": "{0} hours ago",
"REL_MINS": "{0}m",
"REL_MINS_AGO": "{0} minutes ago",
"REL_MONTHS": "{0}mo",
"REL_MONTHS_AGO": "{0} months ago",
"REL_SECS": "{0}s",
"REL_SECS_AGO": "{0} seconds ago",
"REL_WEEKS": "{0}wk",
"REL_WEEKS_AGO": "{0} weeks ago",
"REL_YEARS": "{0}yr",
"REL_YEARS_AGO": "{0} years ago",
"SEARCH": "Search",
"SEARCH_WEB": "Search web",
"SIGNIN": "Sign in",
"SIGNUP": "Sign up",
"SIGNOUT": "Sign out",
"SIGNOUT_ALL": "Sign out of all",
"SIGNOUT_CAPS": "SIGN OUT",
"SUBJECT": "Subject",
"SWITCH_TO": "Switch to account",
"TO_VIEW_MAIL": " to view your emails",
"TOGGLE_PUSH_NOTIF": "Toggle notification status",
"UNABLE_TO_PREVIEW_MAIL": "We are unable to preview your mail.",
"UNABLE_TO_FETCH_UPDATES": "Check back later for updates on stories that you’re following.",
"UNFOLLOW": "Unfollow",
"USER_INTENT_MANAGE_PUBLISHERS": "Manage publishers",
"VIDEO": "Video",
"WEB": "Web",
"WELCOME_BACK": "Welcome back",
"YOU_HAVE": "You have",
"SKIP_ASIDE": "Skip to related content",
"SKIP_MAIN": "Skip to main content",
"SKIP_NAV": "Skip to navigation",
"SCROLL_PROMO_TITLE": "Stay on top of breaking news.",
"SCROLL_PROMO_DESC": "Set your new tab and homepage to Yahoo to keep up with the latest news.",
"SCROLL_PROMO_ADD": "Add it now"
},
"transport": {
"xhr": "/_tdpp_api"
},
"context": {
"bucket": "903",
"device": "desktop",
"lang": "en-GB",
"region": "GB",
"site": "fp"
}
}; /*! NotificationClient - v0.0.13 - 2019-04-30 */
window.NotificationClient = function() {
"use strict";
function a(a, c) {
if (a && !b(a, c)) {
var d = a.className + j + c;
a.className = d
}
}
function b(a, b) {
var c = a && a.className && a.className.split(j);
return !!c && -1 !== c.indexOf(b)
}
function c(a, b) {
if (a) {
var c = a.className && a.className.split(j);
if (c) {
var d = c.indexOf(b);
0 <= d && c.splice(d, 1), a.className = c.join(j)
}
}
}
function d(a, b) {
if (a) {
if (!b) return a;
for (var c in b) b.hasOwnProperty(c) && (a[c] = b[c])
}
}
var e = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(a) {
return typeof a
} : function(a) {
return a && "function" == typeof Symbol && a.constructor === Symbol && a !== Symbol.prototype ? "symbol" : typeof a
}, f = function(a, b) {
if (!(a instanceof b)) throw new TypeError("Cannot call a class as a function")
}, g = function() {
function a(a, b) {
for (var c, d = 0; d < b.length; d++) c = b[d], c.enumerable = c.enumerable || !1, c.configurable = !0, "value" in c && (c.writable = !0), Object.defineProperty(a, c.key, c)
}
return function(b, c, d) {
return c && a(b.prototype, c), d && a(b, d), b
}
}(),
h = "GET",
i = function() {
function a(b) {
f(this, a), this._config = b
}
return g(a, [{
key: "_getRequestUrl",
value: function(a) {
var b = a.url || this._config.service.url;
if (b) {
var c = b.split("?"),
d = {
path: c[0],
queryParams: c[1] ? c[1].split("&") : []
};
c = d.path.split(";"), d.path = c[0], d.matrixParams = c.slice(1);
var e = a.queryParams,
f = a.matrixParams;
f && Object.keys(f).forEach(function(a) {
d.matrixParams.push(encodeURIComponent(a) + "=" + encodeURIComponent(f[a] || ""))
}), e && Object.keys(e).forEach(function(a) {
d.queryParams.push(encodeURIComponent(a) + "=" + encodeURIComponent(e[a] || ""))
});
var g = d.path;
return d.matrixParams.length && (g += ";" + d.matrixParams.join(";")), d.queryParams.length && (g += "?" + d.queryParams.join("&")), g
}
}
}, {
key: "_getRequestBody",
value: function(a) {
return a && JSON.stringify(a) || ""
}
}, {
key: "_parseRequestResult",
value: function(a) {
if ("string" == typeof a) try {
a = JSON.parse(a)
} catch (b) {
a = {}
}
return a = a || {}, {
css: a.css,
count: a.count,
markup: a.html,
newCount: a.newCount
}
}
}, {
key: "read",
value: function(a, b) {
this._attemptRequest(h, a, b)
}
}, {
key: "update",
value: function(a, b) {
this._attemptRequest("PUT", a, b)
}
}, {
key: "create",
value: function(a, b) {
this._attemptRequest("POST", a, b)
}
}, {
key: "_attemptRequest",
value: function(a, b, c) {
var d = this._config.service.attemptCount;
b || (b = {});
var e = this._getRequestUrl(b),
f = this._getRequestBody(b.body);
this._sendRequest({
body: f,
method: a,
url: e
}, d, c)
}
}, {
key: "_sendRequest",
value: function(a, b, c) {
var d = this;
a = a || {};
var e = d._config.service,
f = 1e3 * e.attemptDelay,
g = a,
i = g.url,
j = g.body,
k = new XMLHttpRequest;
k.open(a.method, i), k.responseType = e.responseType, k.timeout = e.timeout;
var l = function() {
0 < b ? (b--, setTimeout(function() {
d._sendRequest(a, b, c)
}, f)) : c && c(new Error("Error: " + k.status + " " + k.statusText), null)
};
k.onload = function() {
if (200 === k.status) {
var b = d._parseRequestResult(k.response || k.responseText);
c && c(null, b, a)
} else l()
}, k.onerror = l, a.method === h ? k.send() : k.send(j)
}
}]), a
}(),
j = " ",
k = function() {
function a(b, c) {
f(this, a);
var d = this;
d._config = b, d._markup = "", d._newCount, d._count, d._request = c
}
return g(a, [{
key: "_replaceAllNotifications",
value: function(a) {
this._markup = a.markup || "", this._newCount = a.newCount && parseInt(a.newCount, 10) || 0, this._count = a.count && parseInt(a.count, 10) || 0
}
}, {
key: "resetNewCount",
value: function() {
this._newCount = 0
}
}, {
key: "_requestNotifications",
value: function(a, b) {
var c = this,
e = c._config.panel,
f = {
count: e.maxCount,
imageTag: e.imageTag
};
a || (a = {}), d(f, a.matrixParams), c._request.read({
matrixParams: f
}, function(a, d) {
!a && d && c._replaceAllNotifications(d), d = d || {}, b && b(a, d)
})
}
}, {
key: "getNotifications",
value: function() {
return {
count: this._count,
markup: this._markup,
newCount: this._newCount
}
}
}, {
key: "fetchNotifications",
value: function(a, b) {
this._requestNotifications(a, b)
}
}]), a
}(),
l = {
panelLoading: "yns-panel-loading",
panelNodeId: "yns-panel",
panelNodeClass: "yns-panel",
panelHideElement: "yns-hide",
panelError: "yns-panel-error",
panelPaddingBtm: "yns-panel-padding-btm"
}, m = function() {
function a(b, c) {
f(this, a);
var d = this;
d._config = b, d._panelNode = null, d._store = c
}
return g(a, [{
key: "_generatePanelMarkup",
value: function(a, c) {
var d, e, f = this._config;
"undefined" != typeof window && (d = window.Notification && "granted" === window.Notification.permission, e = b(document.body, f.promos.eligibleBodyClass));
var g, h = f.promos.enableNotifOnboard && !d && e,
i = h ? '<li class="yns-container yns-promo"><div class="yns-link"><img class="yns-img" src="https://s.yimg.com/cv/ae/notifications/Y-Notif-Panel.png" /><div class="yns-content"><span class="yns-promo-title yns-title">Get Breaking News alerts on your desktop</span><span class="yns-promo-button"><button class="yns-promo-ctr js-push-subscribe" data-subscription-topic="gondor_homerun_news" data-ylk="sec:hd;subsec:notifications-promo;slk:Notify Me;" data-subscription-ylk="sec:hd;subsec:notifications-promo;" >Notify Me</button></span></div></div></li>' : "",
j = c.newCount > f.panel.maxCount,
k = j ? c.newCount : "",
m = f.panel.notificationCenterPath,
n = m ? "" : l.panelHideElement,
o = m ? l.panelPaddingBtm : "";
return g = c.count ? c.markup : '<li class="yns-container yns-empty"><div class="yns-content">{emptyPanelMsg}</div></li>'.replace("{emptyPanelMsg}", f.panel.emptyPanelMsg), a = a.replace("{notifMarkup}", g).replace("{promoMarkup}", i).replace("{hideClass}", n).replace("{notifCenterLink}", m).replace("{paddingClass}", o).replace("{headerMsg}", f.panel.headerMsg).replace(/{notificationCenterNavMsg}/g, f.panel.notificationCenterNavMsg).replace(/{newCount}/g, k)
}
}, {
key: "render",
value: function(a, b) {
var c = this;
if (!c._panelNode) return void(b && b(new Error("No panel parent")));
var d, e, f, g = c._panelNode;
switch (a) {
case "expanded_panel":
d = '<div class="yns-panel-header"><span class="yns-panel-header-title">{headerMsg}</span></div><div class="yns-panel-data"><ul class="yns-notifications {paddingClass}">{promoMarkup}{notifMarkup}</ul></div><div class="yns-panel-footer-action {hideClass}"><a class="yns-navigate-center" href="{notifCenterLink}" data-ylk="sec:hd;subsec:notifications-viewall;slk:{notificationCenterNavMsg};">{notificationCenterNavMsg}</a></div>', f = c._store.getNotifications(), e = c._generatePanelMarkup(d, f), g.innerHTML = e;
break;
case "error_panel":
d = '<div class="yns-panel-error"><span> {errorMsg} </span></div>', e = d.replace("{errorMsg}", c._config.panel.errorMsg), g.innerHTML = e
}
b && b()
}
}, {
key: "createPanelParentNode",
value: function(a) {
a && (a.innerHTML = '<div class="yns-panel" id="yns-panel"></div>', this._panelNode = document.getElementById(l.panelNodeId))
}
}, {
key: "updateBadgeNode",
value: function(a) {
if (a) {
var b = this._store.getNotifications(),
c = b.newCount,
d = this._config.badge.maxCount;
if (c) {
var e = c > d ? d + "+" : c;
a.innerHTML = e
} else a.innerHTML = ""
}
}
}, {
key: "addStyles",
value: function(a) {
if (a && "undefined" != typeof window) {
var b = document.getElementById(this._config.panel.styleTagId);
b || (b = document.createElement("style"), b.type = "text/css", b.id = this._config.panel.styleTagId, b.innerText = a, document.head.appendChild(b))
}
}
}]), a
}(),
n = function() {
function b(a, c, d) {
f(this, b);
var e = this;
e._store = c, e._view = d, e._config = a;
var g = e._config.panel;
e._panelParentNode = document.querySelector(g.parentSelector), e._badgeNode = e._config.badge.selector && document.querySelector(e._config.badge.selector), e._indicatorNode = g.indicatorSelector && document.querySelector(g.indicatorSelector)
}
return g(b, [{
key: "createPanelParentNode",
value: function() {
this._view.createPanelParentNode(this._panelParentNode), this._notifPanelNode = document.getElementById(l.panelNodeId)
}
}, {
key: "refreshPanelNode",
value: function(b, d) {
var e = this;
a(e._notifPanelNode, l.panelLoading), e._store.fetchNotifications(b, function(b, f) {
b ? !e._notifPanelNode.innerHTML && (e._view.render("error_panel"), a(e._notifPanelNode, l.panelLoading)) : (e._view.render("expanded_panel"), e._view.updateBadgeNode(e._badgeNode), e._showBadge(), e._showIndicator(), e._view.addStyles(f.css)), c(e._notifPanelNode, l.panelLoading), d && d(b, f)
})
}
}, {
key: "resetBadge",
value: function() {
var b = this;
b._store.resetNewCount(), b._view.updateBadgeNode(b._badgeNode), a(b._badgeNode, b._config.badge.hideClass)
}
}, {
key: "_showIndicator",
value: function() {
if (this._indicatorNode) {
var b = this._store.getNotifications(),
d = b.newCount;
d ? a(this._indicatorNode, this._config.panel.indicatorClass) : c(this._indicatorNode, this._config.panel.indicatorClass)
}
}
}, {
key: "_showBadge",
value: function() {
var b = this,
d = b._store.getNotifications(),
e = d.newCount;
e ? c(b._badgeNode, b._config.badge.hideClass) : a(b._badgeNode, b._config.badge.hideClass)
}
}]), b
}(),
o = {
promos: {
eligibleBodyClass: "display-push-promos",
enableNotifOnboard: !0
},
badge: {
hideClass: "",
maxCount: 5,
selector: ""
},
panel: {
emptyPanelMsg: "You have no new notifications.",
errorMsg: "",
headerMsg: "Notifications",
imageTag: "img:40x40|2|80",
indicatorClass: "yns-indicator",
indicatorSelector: null,
maxCount: 6,
notificationCenterNavMsg: "View all {newCount} notifications",
notificationCenterPath: "",
styleTagId: "notificationStyles",
parentSelector: null
},
service: {
attemptCount: 2,
attemptDelay: 1,
url: null,
responseType: "json",
timeout: 1500
}
}, p = function() {
function a(b) {
f(this, a);
var c = this;
c.config = c._parseConfig(b);
var d = c._validateRequiredConfigs();
d && (c._request = new i(c.config), c._store = new k(c.config, c._request), c._view = new m(c.config, c._store), c._panelController = new n(c.config, c._store, c._view), c._panelController.createPanelParentNode(), c._assignHelperMethods())
}
return g(a, [{
key: "_parseConfig",
value: function(a) {
var b = {};
for (var c in d(b, o), b)
if (b.hasOwnProperty(c)) {
var f = b[c],
g = a[c];
"object" === ("undefined" == typeof f ? "undefined" : e(f)) ? d(f, g) : b[c] = a[c]
}
return b
}
}, {
key: "_validateRequiredConfigs",
value: function() {
var a = this.config;
return !(!a.panel.parentSelector || !a.service.url)
}
}, {
key: "_assignHelperMethods",
value: function() {
var a = this;
a.helpers = {
refreshPanelNode: a._panelController.refreshPanelNode.bind(a._panelController),
resetBadge: a._panelController.resetBadge.bind(a._panelController),
resetIndicator: function() {
c(a._panelController._indicatorNode, a.config.panel.indicatorClass)
}
}
}
}]), a
}();
return p
}(); /*! SubscriptionHelper - v3.8.11 - 2019-05-07 */
! function() {
function a(a, b, c) {
this.init(a, b, c)
}
var b = "BrowserSubscriptionHelper",
c = "chrome",
d = "error",
e = "firefox",
f = "info",
g = "pushNotifications",
h = "undefined",
i = "Unsupported Browser.",
j = "No_SW_registration",
k = "No_PushManager_Subscription",
l = "Subscription_Present",
m = "granted",
n = "denied",
o = "yahooNotifications",
p = 2,
q = "subscriptions",
r = "type",
s = "push",
t = "display-push-promos",
u = "js-push-subscribe",
v = "rapidnofollow",
w = "subscriptionFail",
x = 864e5;
a.prototype = {
init: function(a, b, c) {
var d = this;
d.beaconer = b, d.tracker = c, d.config = {
bucket: a.bucket,
confirmationNotification: a.confirmationNotification || {},
overlay: a.overlay || {},
serviceWorkerScope: a.serviceWorkerScope || "/",
serviceWorkerUrl: a.serviceWorkerUrl,
spaceId: a.spaceId,
subscriptionService: a.subscriptionService || {},
supportedBrowsers: a.supportedBrowsers || {},
userAgent: a.userAgent || {}
}, d._setIsPrivateSession(), d._attachPermissionUpdateHandle(), d._updateAttributesForSubscribedUser()
},
checkIsPrivateSession: function(a) {
var b = this;
typeof b.isPrivateSession === h ? b._setIsPrivateSession(a) : a && a(null, b.isPrivateSession)
},
checkIsSupportedBrowser: function() {
for (var a = this, b = a.config.userAgent, c = b.browserName, d = b.browserVersion, e = b.os || b.osName, f = a.config.supportedBrowsers, g = f[c] || {}, h = !1, i = !1, j = g.os && g.os.length, k = 0; k < j; k++)
if (e.indexOf(g.os[k]) > -1) {
i = !0;
break
}
return !a.isPrivateSession && (!g.minVersion || d >= g.minVersion) && (!g.maxVersion || d <= g.maxVersion) && (!g.useServiceWorker || g.useServiceWorker && "serviceWorker" in navigator) && i && (h = !0), h
},
checkSubscriptionChurn: function(a) {
function b(b, d) {
var e = c._parseGCMSubscriptionId(d) || null,
g = b.deviceId || null,
h = b.subscriptionState || null,
i = d && d.error === w,
j = !g && "granted" === b.state && "started" === d.onboardState,
k = g && "granted" === b.state && "started" === d.onboardState && !d.error,
l = i || j || k,
m = "subsPushMngrResync";
return i ? m = "subsOnepushResync" : k && (m = "subsFCMResync"), l ? (c._sendBeacon(f, {
code: m,
deviceId: g,
idbDeviceId: e,
onboardTime: d.onboardTime
}), void(a && a(null, {
isOnboardError: !0,
pushManagerChurn: null
}))) : void(e && e !== g && (!d.churnCheckTime || d.churnCheckTime < d.subscriptionTime) ? c.logSubscriptionChurnCheck(function(b) {
return b ? void(a && a(b)) : (c._sendBeacon(f, {
code: "subChurn",
idbDeviceId: e,
deviceId: g,
subscriptionState: h
}), void(a && a(null, {
isOnboardError: !1,
pushManagerChurn: !0
})))
}) : a && a(null, {
isOnboardError: !1,
pushManagerChurn: !1
}))
}
var c = this;
return c.checkIsSupportedBrowser(g) ? void c.fetchPushPermission(function(d, e) {
return d || !e || e && "granted" !== e.state ? void(a && a(d, {
isOnboardError: null,
pushManagerChurn: null
})) : void c.getSubscriptionLog(function(c, d) {
return c ? void(a && a(c)) : void(e && d ? b(e, d) : a && a(null, {
isOnboardError: !1,
pushManagerChurn: !1
}))
})
}) : void(a && a(new Error(i)))
},
fetchPushPermission: function(a) {
if (a) {
var b = this;
return b.checkIsSupportedBrowser() && b.config.userAgent.browserName === c ? void b._fetchPushPermissionChrome(a) : void a(new Error(i, null))
}
},
requestPushPermission: function(a, b) {
if (b) {
var d = this;
return d.checkIsSupportedBrowser() && (d.logOnboardingStart(), d.config.userAgent.browserName === c) ? void d._requestPushPermissionChrome(a, b) : void b(new Error(i, null))
}
},
_fetchPushPermissionChrome: function(a) {
var b = this,
c = Notification && Notification.permission;
c === m ? navigator.serviceWorker.getRegistration(b.config.serviceWorkerScope).then(function(a) {
return a && a.pushManager.getSubscription()
}).then(b._buildPermissionObjectChrome.bind(b)).then(function(b) {
a(null, b)
})["catch"](function(c) {
b._sendBeacon(d, {
code: "brwsrPermFetchError",
message: c
}), a(c)
}) : a(null, b._buildPermissionObjectChrome(null))
},
_requestPushPermissionChrome: function(a, b) {
var c = this,
e = c.config.serviceWorkerUrl,
g = c.config.serviceWorkerScope;
Notification && e && g && ("default" === Notification.permission && (c._trackLinkView({
itc: "1",
sec: a.sec,
slk: "notification permission request",
subsec: a.subsec
}), c._sendBeacon(f, {
code: "notificationPermissionRequest",
message: a.sec
})), Notification.requestPermission().then(function() {
return c._doRegisterServiceWorker(e, g)
}).then(c._doPushManagerSubscribe.bind(c)).then(c._buildPermissionObjectChrome.bind(c)).then(function(a) {
c._sendBeacon(f, {
code: "brwsrPermReqSuccess",
message: a.state
}), b(null, a)
})["catch"](function(a) {
c._sendBeacon(d, {
code: "brwsrPermReqError",
message: a
}), b(a, null)
}))
},
_doRegisterServiceWorker: function(a, b) {
var c = this;
return navigator.serviceWorker.register(a, {
scope: b
}).then(function(a) {
return c._sendBeacon(f, {
code: "svcWkrRegSuccess"
}), a
}, function(a) {
c._sendBeacon(d, {
code: "svcWkrRegError",
message: a
})
})
},
_doPushManagerSubscribe: function(a) {
var b = this;
if (window.Promise && a) return new Promise(function(b, c) {
if (Notification && "granted" === Notification.permission) {
var d = a.installing || a.waiting;
d ? d.addEventListener("statechange", function(a) {
"activated" === a.target.state && b()
}) : a.active ? b() : c("Service Worker not active")
} else c("Permission not granted")
}).then(function() {
return a.pushManager.subscribe({
userVisibleOnly: !0
})
}).then(function(a) {
if (!a || !a.endpoint) throw "Missing subscription endpoint";
return b.logPushManagerSuccess(a.endpoint), b._sendBeacon(f, {
code: "PushMngrSubSuccess",
deviceId: a.endpoint
}), a
})["catch"](function(a) {
b._sendBeacon(d, {
code: "PushMngrSubFail",
message: a
}), b.logPushManagerFailure()
})
},
_buildPermissionObjectChrome: function(a) {
var b;
return b = typeof a === h ? j : null === a ? k : l, {
deviceId: a && this._parseGCMSubscriptionId(a),
state: Notification && Notification.permission,
subscriptionKeys: a && btoa(JSON.stringify(a)),
subscriptionState: b
}
},
_parseGCMSubscriptionId: function(a) {
var b, c, d = /^https\:\/\/(fcm|android)\.googleapis\.com\/(gcm|fcm)\/send\/(.*)$/;
return a && a.endpoint && (b = a.endpoint.match(d), c = b && b.length && b[3]), c
},
_sendBeacon: function(a, c) {
var d = this;
d.beaconer && a && c && ("function" == typeof d.beaconer ? d.beaconer(a, b, c) : "function" == typeof d.beaconer[a] && d.beaconer[a](b, c))
},
_trackClick: function(a, b) {
var c = this;
c.tracker && a && a.sec && a.slk && typeof a._p !== h && c.tracker.beaconClick(a.sec, a.slk, a._p, a, a.outcome, b)
},
_trackLinkView: function(a) {
var b = this;
b.tracker && a && a.sec && a.slk && b.tracker.beaconLinkViews([{
sec: a.sec,
t1: a.t1,
t2: a.t2,
_links: [a]
}])
},
_setIsPrivateSession: function(a) {
function b() {
f.isPrivateSession = !0, a && a(null, f.isPrivateSession)
}
function d() {
f.isPrivateSession = !1, a && a(null, f.isPrivateSession)
}
var f = this,
g = f.config.userAgent.browserName || "";
if (typeof f.isPrivateSession === h) try {
if (g.toLowerCase() === c) {
var i = window.RequestFileSystem || window.webkitRequestFileSystem;
i && i(window.TEMPORARY, 100, d, b)
} else if (g.toLowerCase() === e && window.indexedDB) {
var j = window.indexedDB.open("test");
j.onerror = b, j.onsuccess = d
}
} catch (k) {
d()
} else a && a(null, f.isPrivateSession)
},
_attachPermissionUpdateHandle: function(a) {
var b = this;
return b.checkIsSupportedBrowser(g) ? void(navigator && navigator.permissions && navigator.permissions.query && navigator.permissions.query({
name: "notifications"
}).then(function(c) {
return c ? (c.onchange = function() {
b.getSubscriptionLog(function(a, d) {
d || (d = {}), d.code = "userPermissionUpdate", d.newState = c.state, b._sendBeacon(f, d)
})
}, void(a && a(null, !0))) : void(a && a(null, !1))
})) : void(a && a(new Error(i), !1))
},
_convertAllOnepushTopicsToRivendell: function(a, b) {
var c = this;
b = b || {};
var d = b.subscriptionKeys,
e = {
channel_id: d,
device_id: b.deviceId,
registration_id: a
}, f = Object.assign(e, c.getEssentialAttributes()),
g = {
method: "POST",
operation: "update",
serviceResource: "subscriptions.oToR"
};
return c.callSubscriptionService(g, f), !0
},
_updateAttributesForSubscribedUser: function() {
if (!window.indexedDB) return !1;
var a = this;
a._readEntryInDB(function(b, c) {
if (b) return !1;
c = c || {};
var d = c.lastAttributeUpdateTime,
e = c.registrationId;
return !(Date.now() - d <= x) && void a.fetchPushPermission(function(b, d) {
if (b) return !1;
d = d || {};
var f = d.subscriptionKeys;
if (d.state === m && "completed" === c.onboardState && f) {
var g = {
channel_id: f,
device_id: d.deviceId
};
e && (g.registration_id = e, a._convertAllOnepushTopicsToRivendell(e, d));
var h = Object.assign(g, a.getEssentialAttributes()),
i = {
method: "POST",
operation: "update",
serviceResource: "subscriptions.setAttributes"
};
return a.callSubscriptionService(i, h, function(b, c) {
if (!b) {
c = c || {}, e = e || c.registrationId || c.g0 && c.g0.data && c.g0.data.registrationId;
var d = {
lastAttributeUpdateTime: Date.now()
};
e && (d.registrationId = e), a._setEntryInDB(d)
}
}), !0
}
return !1
})
})
},
logOnboardingStart: function(a, b) {
a = a || {}, this._initDB(a, b)
},
logOnboardingCompleted: function(a, b) {
this._setEntryInDB({
onboardState: "completed",
origin: a,
error: void 0
}, b)
},
logPushManagerSuccess: function(a, b) {
this._setEntryInDB({
endpoint: a,
subscriptionTime: (new Date).getTime()
}, b)
},
logPushManagerFailure: function(a) {
this._setEntryInDB({
error: "pushManagerFail"
}, a)
},
logSubscriptionFailure: function(a) {
this._setEntryInDB({
error: w
}, a)
},
logSubscriptionChurnCheck: function(a) {
this._setEntryInDB({
churnCheckTime: (new Date).getTime()
}, a)
},
clearErrorLog: function(a) {
this._setEntryInDB({
error: void 0
}, a)
},
getSubscriptionLog: function(a) {
this._readEntryInDB(a)
},
_openDB: function(a) {
var b = this,
c = window.indexedDB.open(o, p);
c.onupgradeneeded = function(c) {
var e = c.target.result,
f = e.createObjectStore(q, {
keyPath: r
});
f.transaction.onerror = function(c) {
var e = new Error("Failed upgrading: " + c.target.errorCode);
b._sendBeacon(d, {
code: "IDBUpgradeFail",
message: e.message
}), a && a(e)
}
}, c.onsuccess = function(b) {
var c = b.target.result;
a && a(null, c)
}, c.onerror = function(c) {
var e = new Error("Failed opening: " + c.target.errorCode);
b._sendBeacon(d, {
code: "IDBOpenFail",
message: e.message
}), a && a(new Error(e))
}
},
_initDB: function(a, b) {
var c = this,
e = (new Date).getTime(),
g = "IDBInitFail",
h = "Failed initilazing: ";
c._openDB(function(i, j) {
if (i) return b && b(i);
var k = c._buildEntryObject(a),
l = j.transaction(q, "readwrite").objectStore(q),
m = l.put(k);
m.onsuccess = function(a) {
var d = (new Date).getTime();
b && b(null, k), c._sendBeacon(f, {
code: "initIndexedDBDuration",
message: d - e
}), j.close()
}, m.onerror = function(a) {
var e = new Error(h + a.target.errorCode);
c._sendBeacon(d, {
code: g,
message: e.message
}), b && b(e), j.close()
}
})
},
_readEntryInDB: function(a) {
var b = this,
c = (new Date).getTime();
b._openDB(function(e, g) {
if (e) return a && a(e);
var h = g.transaction(q).objectStore(q),
i = h.get(s);
i.onsuccess = function(d) {
var e = (new Date).getTime();
a && a(null, i.result), b._sendBeacon(f, {
code: "readIndexedDBDuration",
message: e - c
}), g.close()
}, i.onerror = function(c) {
var e = new Error("Failed Reading: ", c.target.errorCode);
b._sendBeacon(d, {
code: "IDBReadFail",
message: e.message
}), a && a(e), g.close()
}
})
},
_setEntryInDB: function(a, b) {
var c = this,
e = (new Date).getTime();
c._readEntryInDB(function(g, h) {
g || !h ? c._initDB(c._buildEntryObject(a, h), b) : c._openDB(function(g, i) {
if (g) return b && b(g);
var j = i.transaction(q, "readwrite").objectStore(q),
k = j.put(c._buildEntryObject(a, h));
k.onsuccess = function(a) {
var d = (new Date).getTime();
b && b(null, !0), c._sendBeacon(f, {
code: "updateIndexedDBDuration",
message: d - e
}), i.close()
}, k.onerror = function(a) {
c._sendBeacon(d, {
code: "IDBUpdateFail",
message: g
}), b && b(new Error("Failed updating: ", a.target.errorCode)), i.close()
}
})
})
},
_buildEntryObject: function(a, b) {
var c = this;
a = a || {}, b = b || {};
var d = (new Date).getTime(),
e = a.registrationId || b.registrationId,
f = {
bucket: a.bucket || b.bucket || c.config.bucket,
churnCheckTime: a.churnCheckTime || b.churnCheckTime,
endpoint: a.endpoint || b.endpoint,
error: a.error || b.error,
lastAttributeUpdateTime: a.lastAttributeUpdateTime || b.lastAttributeUpdateTime,
onboardState: a.onboardState || b.onboardState || "started",
onboardTime: b.onboardTime || d,
origin: a.origin || b.origin,
permissionState: Notification && Notification.permission || "unsuported",
spaceId: a.spaceId || b.spaceId || c.config.spaceId,
subscriptionTime: a.subscriptionTime || b.subscriptionTime,
updateTime: d
};
return e && (f.registrationId = e), a.hasOwnProperty("error") && void 0 === a.error && (f.error = void 0, "started" === f.onboardState && (f.onboardState = "completed", f.onboardTime = d)), f[r] = s, f
},
_sendRequest: function(a, b, c) {
function d() {
b > 0 ? (b -= 1, setTimeout(function() {
e._sendRequest(a, b, c)
}, f)) : c && c(new Error(j.statusText))
}
if (a) {
var e = this,
f = 2e3,
g = a.url,
h = a.headers,
i = a.body,
j = new XMLHttpRequest;
b = "number" == typeof b ? b : 3, j.open(a.method, g), j.responseType = "json", j.timeout = 1e4;
for (var k in h) h.hasOwnProperty(k) && j.setRequestHeader(k, h[k]);
j.onload = function() {
if (200 === j.status) {
var a = j.response;
c && c(null, a)
} else d()
}, j.onerror = function() {
d()
}, j.ontimeout = function() {
d()
}, "GET" === a.method ? j.send() : j.send(i)
}
},
callSubscriptionService: function(a, b, c) {
a = a || {};
var d, e = this.config.subscriptionService,
f = "",
g = "";
a.matrixParams && Object.keys && (Object.keys(a.matrixParams).forEach(function(b) {
f += ";" + (encodeURIComponent(b) + "=" + encodeURIComponent(a.matrixParams[b] || ""))
}), f && (f += ";")), g = [].concat(e.protocol ? e.protocol + "://" : []).concat(e.host || []).concat(e.path ? e.path.replace("RESOURCE_PLACEHOLDER", a.serviceResource + f) : []).join(""), "GET" === a.method ? (g.indexOf("resource/") < 0 && (g.endsWith && !g.endsWith("/") && (g += "/"), g += "resource/" + a.serviceResource + f), d = {
url: g,
method: "GET"
}) : "POST" === a.method && (d = {
body: JSON.stringify({
requests: {
g0: {
resource: a.serviceResource,
operation: a.operation,
params: a,
body: b
}
},
context: e.context || {}
}),
headers: {
"content-type": "application/json"
},
url: g,
method: "POST"
}), this._sendRequest(d, 3, c)
},
readTopicSubscription: function(a, b, c) {
if (!a || !b) return void(c && c(new Error("Missing required arguments")));
if (!window.indexedDB) return void(c && c(new Error("IndexedDB connection failed")));
var d = this;
d._readEntryInDB(function(e, f) {
if (e) return void(c && c(e));
f = f || {};
var g = f.registrationId,
h = {
matrixParams: {
channel_id: b,
operation: "read",
serviceResource: "subscriptions.hasSubscription",
target_id: a
},
method: "GET",
serviceResource: "subscriptions.hasSubscription"
};
g && (h.matrixParams.registration_id = g), d.callSubscriptionService(h, null, c)
})
},
setTopicSubscription: function(a, b, c, e, f) {
if (!a || !c || !e) return void(f && f(new Error("Missing required arguments")));
if (!window.indexedDB) return void(f && f(new Error("IndexedDB connection failed")));
var g = this;
g._readEntryInDB(function(h, i) {
if (h) return void(f && f(h));
i = i || {};
var j = i.registrationId,
k = {
channel_id: e,
device_id: c,
target_id: a
};
j && (k.registration_id = j);
var l = Object.assign(k, g.getEssentialAttributes()),
m = {
method: "POST",
operation: "update",
serviceResource: b ? "subscriptions.setSubscription" : "subscriptions.removeSubscription"
};
g.callSubscriptionService(m, l, function(a, b) {
return !a && (b = b || {}, j = j || b.registrationId || b.g0 && b.g0.data && b.g0.data.registrationId) ? void g._setEntryInDB({
registrationId: j
}, function(c) {
c && g._sendBeacon(d, {
code: "registrationIDBEntryError",
message: c.message
}), f.call(g, a, b)
}) : void f.apply(g, Array.prototype.slice.call(arguments))
})
})
},
checkIsPushMuted: function(a, b) {
if (!a || !b) return void(b && b(new Error("Missing required topic")));
var c = this;
c.fetchPushPermission(function(d, e) {
e && e.state === m && e.subscriptionKeys ? c.readTopicSubscription(a, e.subscriptionKeys, function(a, c) {
var d = c && c.isSubscribed;
b(null, !d)
}) : b(null, !0)
})
},
pushNotificationSubscribe: function(a, b) {
if (!a || !a.topic) return void(b && b(new Error("Missing required option: topic")));
a = JSON.parse(JSON.stringify(a));
var c = this,
e = c.config.overlay["default"],
f = a.topic,
g = a.trackingParams || {
sec: "hd"
};
g.subsec = "browser-prompt", g.aid = f, a.trackingParams = g, c.fetchPushPermission(function(f, h) {
return f || !h ? (c._sendBeacon(d, {
code: "permRead",
message: f.message
}), void(b && b(new Error("Could not read push permission")))) : h.state === n ? (a.trackingParams = null, void c._handlePermissionDenied(a, b)) : h.state === m && h.deviceId && h.subscriptionKeys ? (a.trackingParams = null, void c._handlePermissionGranted(h, a, b)) : (a.showInstructionsDefault && e && h.state !== m && c.renderInstructionOverlay(e.overlayId, e.imageUrl, e.imageWidth, e.imageHeight, e.xOffset, e.yOffset), void c.requestPushPermission(g, function(f, g) {
return a.showInstructionsDefault && e && c.removeInstructionsOverlay(e.overlayId), !f && g ? g.state === m ? void c._handlePermissionGranted(g, a, b) : g.state === n ? void c._handlePermissionDenied(a, b) : void c._handlePermissionDismissed(a, b) : (c._sendBeacon(d, {
code: "permReq",
message: f.message
}), void(b && b(new Error("Push permission request failure"))))
}))
})
},
_handlePermissionGranted: function(a, b, c) {
b = b || {};
var e = this,
f = b.trackingParams,
g = b.topic,
h = function(b, f) {
b ? a.deviceId && e.logSubscriptionFailure() : (e.hidePushSubscriptionPromos(), e.getSubscriptionLog(function(a, b) {
b && "completed" !== b.onboardState && e.logOnboardingCompleted(g)
})), b && e._sendBeacon(d, {
code: "failureAfterPerm",
message: b && b.message
}), c && c(b, f)
};
a && a.state === m && g ? (f && (f.slk = "permission-allow", f._p = 1, e._trackClick(f)), this.setTopicSubscription(g, !0, a.deviceId, a.subscriptionKeys, h)) : c && c(new Error("Missing required params in handler"))
},
_handlePermissionDenied: function(a, b) {
a = a || {};
var c = this,
d = c.config.overlay.denied,
e = a.trackingParams;
e && (e.slk = "permission-block", e._p = 2, this._trackClick(e)), a.showInstructionsDenied && d && this.renderInstructionOverlay(d.overlayId, d.imageUrl, d.imageWidth, d.imageHeight, d.xOffset, d.yOffset), b && b(new Error("Permission denied by user"))
},
_handlePermissionDismissed: function(a, b) {
a = a || {};
var c = a.trackingParams;
c && (c.slk = "permission-dismiss", c._p = 0, this._trackClick(c)), b && b(new Error("Permission not granted by user"))
},
pushNotificationUnsubscribe: function(a, b) {
var c = this;
a && c.fetchPushPermission(function(d, e) {
return e ? void c.setTopicSubscription(a, !1, e.deviceId, e.subscriptionKeys, b) : void(b && b(new Error("Could not read permission")))
})
},
renderInstructionOverlay: function(a, b, c, d, e, f) {
var g = this;
if (a && b && c && d) {
var h = document.createElement("div"),
i = document.createElement("div"),
j = "";
h.id = a, h.setAttribute("style", "position:fixed; background-color:rgba(236, 236, 236, 0.95); top:0; left:0; width:100%; height:100%; z-index:100;"), "number" != typeof e && (j += "margin-left:auto; margin-right:auto;"), "number" != typeof f && (j += " margin-top:117px;"), j && i.setAttribute("style", j), i.setAttribute("style", "width:" + c + "px;height:" + d + "px;background: url(" + b + ") 0 0/" + c + "px " + d + "px no-repeat;" + ("number" == typeof e ? "margin-left:" + e + "px;" : "") + ("number" == typeof f ? "margin-top:" + f + "px;" : "")), h.appendChild(i), document.body.appendChild(h), g.removeInstructionsOverlay && (document.onkeydown = function(b) {
b = b || window.event;
var c;
c = "key" in b ? "Escape" === b.key || "Esc" === b.key : 27 === b.keyCode, c && g.removeInstructionsOverlay(a)
}, h.onclick = function(b) {
g.removeInstructionsOverlay(a)
})
}
},
removeInstructionsOverlay: function(a) {
var b = document.getElementById(a);
b && document.body.removeChild(b)
},
shouldPromotePushNotifications: function() {
return this.checkIsSupportedBrowser(g) && Notification.permission !== m
},
shouldPromotePushNotificationsForTopic: function(a, b) {
var c = this;
return a && c.checkIsSupportedBrowser(g) ? void c.checkIsPushMuted(a, function(a, c) {
return a ? void b(a, !1) : void b(void 0, c)
}) : void b(void 0, !1)
},
showPushSubscriptionPromos: function() {
this.shouldPromotePushNotifications() && document.body.classList.add(t)
},
hidePushSubscriptionPromos: function() {
document.body.classList.remove(t)
},
_stringParseKV: function(a, b, c) {
var d = {};
if (!a) return d;
b = b || ";", c = c || ":";
for (var e = a.split(b), f = 0; f < e.length; f += 1) {
var g = e[f],
h = g.indexOf(c),
i = g.substring(0, h),
j = g.substring(h + 1);
i = i.trim ? i.trim() : i, j = j.trim ? j.trim() : j, i && (d[i] = j)
}
return d
},
_delegateDOMEvent: function(a, b, c, d) {
if (a && b && c && d) {
var e = document.querySelector(b);
e && e.addEventListener(a, function(a) {
for (var b = a.target; b && a.currentTarget !== b;) {
if (b.classList.contains(c)) {
d.call(b, a);
break
}
b = b.parentNode
}
}, !1)
}
},
addPromoButtonDelegator: function() {
var a = this;
a._delegateDOMEvent("click", "body", u, function(b) {
a.handlePromoButtonSubscription(this)
})
},
handlePromoButtonSubscription: function(a) {
if (a) {
var b = this,
c = a.getAttribute("data-subscription-topic"),
d = a.getAttribute("data-subscription-ylk"),
e = d && b._stringParseKV(d),
f = "false" === a.getAttribute("data-subscription-instructions-default"),
g = "false" === a.getAttribute("data-subscription-instructions-denied");
c && e && (b._trackClick(b._stringParseKV(d)), b.pushNotificationSubscribe({
showInstructionsDefault: !f,
showInstructionsDenied: !g,
topic: c,
trackingParams: e
}, b.displayWelcomeNotification.bind(b)))
}
},
trackPromoButtonsLinkViews: function() {
for (var a, b, c = this, d = document.getElementsByClassName(u), e = 0; d && e < d.length; e += 1) d[e].classList.contains(v) && c._isVisible(d[e]) && (a = d[e].getAttribute("data-subscription-ylk") || "", b = c._stringParseKV(a), b && b.slk && (b.slk = "[manual] " + b.slk, c._trackLinkView(b)), d[e].classList.remove(v))
},
_isVisible: function(a) {
if (a) {
var b = window.getComputedStyle(a, null);
return b && "none" !== b.display && "hidden" !== b.visibility
}
},
displayWelcomeNotification: function() {
var a = this,
b = a.config.confirmationNotification;
Notification.permission === m && b.enabled && new Notification(b.title, {
body: b.body,
icon: b.icon
})
},
getEssentialAttributes: function() {
var a = -((new Date).getTimezoneOffset() / 60),
b = "UTC" + a,
c = {
utcTz: b
};
if (window.Intl) try {
c.tz = window.Intl.DateTimeFormat().resolvedOptions().timeZone
} catch (d) {}
return c
}
}, typeof module !== h && module.exports ? module.exports = a : typeof window !== h && (window.SubscriptionHelper = a)
}();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment