Mini Kabibi Habibi
/* Accept Extension UI */
(function (wa, $) {
var ui = (wa.UI = wa.UI || {});
var _window = wa.Core.Window;
var _external = wa.Utils.External;
var _settings = wa.Utils.Settings;
var _instrument = wa.Utils.Instrument;
var browserCode = _instrument.getBrowserTypeCode();
ui.accept_extension = function () {
var $el = {
balloonCard: $("#balloon__card"),
headerText: $("#content__text-header"),
contentText: $("#content__text-description"),
acceptBtn: $("#content__actions-accept"),
declineBtn: $("#content__actions-decline"),
};
show = function () {
_window.ready(function () {
var payload = JSON.parse(_external.getArgument("overlay_data"));
init(payload);
_window.show();
});
},
init = function (payload) {
var lang = wa.Utils.Lang(wa.Utils.Lang.ResType.NEW_TAB_TOAST).get;
var toastCount = Number(payload["toast_count"]);
// Polyfill of isNaN for IE version < 12;
Number.isNaN = Number.isNaN || function isNaN(input) {
return typeof input === "number" && input !== input;
};
// Validate toastCount is valid;
if (Number.isNaN(toastCount)) {
_window.close();
return;
}
// Set window size
_window.setHeight("255");
_window.setWidth("505");
// Add overlay localized content
var headerLocale = "";
var contentLocale = "";
var acceptLocale = "";
var declineLocale = "";
if (toastCount === 0) {
headerLocale = lang("NEW_TAB_EXTENSION_HEADER_VARIANT_1");
contentLocale = lang("NEW_TAB_EXTENSION_TOAST_CONTENT_VARIANT_1");
acceptLocale = lang("NEW_TAB_EXTENSION_TOAST_ACCEPT");
declineLocale = lang("NEW_TAB_EXTENSION_TOAST_REMIND_LATER");
} else if (toastCount === 1) {
headerLocale = lang("NEW_TAB_EXTENSION_HEADER_VARIANT_2");
contentLocale = lang("NEW_TAB_EXTENSION_TOAST_CONTENT_VARIANT_2");
acceptLocale = lang("NEW_TAB_EXTENSION_TOAST_ACCEPT");
declineLocale = lang("NEW_TAB_EXTENSION_TOAST_DECLINE");
}
$el.contentText.html(contentLocale);
$el.headerText.html(headerLocale);
$el.acceptBtn.html(acceptLocale);
$el.declineBtn.html(declineLocale);
updateSettings(toastCount);
$el.acceptBtn.click(function () {
chrome.webview.hostObjects.wa_external.install_extension(2, "kanjcmmieblbpbihaafnedamppkhfadn", "");
_settings.set("new_tab_experience_complete", true, "1");
_window.close();
});
$el.declineBtn.click(function () {
updateSettings(toastCount);
_window.close();
});
},
updateSettings = function (toastCount) {
var currentTimeInSeconds = Math.round(new Date().getTime() / 1000);
_settings.set("new_tab_experience_last_shown", currentTimeInSeconds.toString(), "1");
_settings.set("new_tab_experience_toast_count", ++toastCount, "1");
if (toastCount > 1) {
_settings.set("new_tab_experience_complete", true, "1");
}
},
return {
show: show,
};
};
})((window.WebAdvisor = window.WebAdvisor || {}), jQuery);
$(function () {
var balloon = new WebAdvisor.UI.accept_extension();
balloon.show();
});
//F6A65E4D5219A2537582812069824C147D9B5062223FB31C02CBB690B85CC07F6B6BF173882A12ABF9F98BB4F877F62D11DDF38A1CEE817F50F9900BE3BF3CC6++