From ce611efb04fde07426de3a819d4a175da8681fa8 Mon Sep 17 00:00:00 2001 From: D8H Date: Thu, 23 Nov 2023 18:19:18 +0100 Subject: [PATCH] [Community] [CrazyGames] Upgrade to 2.x of CrazyGames SDK (#1099) --- extensions/community/CrazyGamesAdApi.json | 554 +++++++++++-------- scripts/lib/ExtensionsValidatorExceptions.js | 6 + 2 files changed, 339 insertions(+), 221 deletions(-) diff --git a/extensions/community/CrazyGamesAdApi.json b/extensions/community/CrazyGamesAdApi.json index 8e8d201ce..dd3bc8b83 100644 --- a/extensions/community/CrazyGamesAdApi.json +++ b/extensions/community/CrazyGamesAdApi.json @@ -1,15 +1,19 @@ { "author": "", - "category": "Third-party", + "category": "Ads", "extensionNamespace": "", - "fullName": "CrazyGamesAds Extension", - "helpPath": "https://docs.crazygames.com/sdk/html5/", + "fullName": "CrazyGames SDK", + "helpPath": "/extensions/crazy-games-ad-api/", "iconUrl": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iODkiIGhlaWdodD0iMTAwIiB2aWV3Qm94PSIwIDAgODkgMTAwIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTg0LjkwMzQgMjUuODkyOUM4NS4wNzI3IDE4LjY4MjQgODQuNjQ5NCA2LjExNjk0IDgwLjA3NzYgMC44NzQ4NTlDNzcuNTcyOSAtMS45OTY2NCA3MS42MTgzIDIuODA4MDEgNjcuNzY2MSA2LjUxOTA5QzYxLjM4MSAzLjQwNzcxIDUzLjUzNTUgMS44NzY3MSA0My45OTY4IDEuODc2NzFDMzQuNDU4IDEuODc2NzEgMjYuNjE5NiAzLjQxNDc2IDIwLjI0MTYgNi41MTkwOUMxNi4zODI0IDIuODA4MDEgMTAuNDM0OCAtMS45ODk1OSA3LjkzMDE0IDAuODgxOTE1QzMuMzY1MzcgNi4xMT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xMTQgMzQuODg4NFoiIGZpbGw9IiMwQzBEMTQiLz4KPC9zdmc+Cg==", - "shortDescription": "Enable developer to use CrazyGamesAds SDK.", - "version": "1.0.0", - "description": "Enable developer to use CrazyGamesAds SDK", + "shortDescription": "Allow games to be hosted on CrazyGames website and display ads.", + "version": "1.1.0", + "description": "Please refer to [CrazyGames' guide](https://docs.crazygames.com/sdk/html5/intro/) to know when to call the different actions.", + "origin": { + "identifier": "CrazyGamesAdApi", + "name": "gdevelop-extension-store" + }, "tags": [ "api", "crazygames" @@ -22,9 +26,25 @@ { "fullName": "", "functionType": "Action", - "name": "onSceneLoaded", + "name": "onFirstSceneLoaded", "sentence": "", "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "gdjs._crazyGamesExtension = {", + " isSdkReady: false,", + " isPlayingVideoAd: false,", + " hasVideoAdJustFinishedPlaying: false,", + " isAdBlockerDetected: false,", + " links: new Map(),", + "};", + "" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + }, { "type": "BuiltinCommonInstructions::Standard", "conditions": [], @@ -49,6 +69,78 @@ "functionType": "Action", "name": "onScenePostEvents", "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": "gdjs._crazyGamesExtension.hasVideoAdJustFinishedPlaying = false;", + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "Load CrazyGames SDK.", + "fullName": "Load SDK", + "functionType": "Action", + "name": "LoadSDK", + "private": true, + "sentence": "Load CrazyGames SDK", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const logger = new gdjs.Logger(\"CrazyGames SDK\");\r", + "const addScript = (src) => {\r", + " return new Promise((resolve, reject) => {\r", + " const scriptElement = document.createElement('script');\r", + "\r", + " scriptElement.setAttribute('src', src);\r", + " scriptElement.addEventListener('load', resolve);\r", + " scriptElement.addEventListener('error', reject);\r", + "\r", + " document.body.appendChild(scriptElement);\r", + " });\r", + "}\r", + "addScript('https://sdk.crazygames.com/crazygames-sdk-v2.js').then(() => {\r", + " gdjs._crazyGamesExtension.isSdkReady = true;\r", + " logger.log(\"CrazyGames SDK successfully initialized.\");\r", + "})" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "Check if the CrazyGames SDK is ready to be used.", + "fullName": "CrazyGames SDK is ready", + "functionType": "Condition", + "name": "IsSDKLoaded", + "sentence": "CrazyGames SDK is ready", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": "eventsFunctionContext.returnValue = gdjs._crazyGamesExtension.isSdkReady;", + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "Let CrazyGames know gameplay started.", + "fullName": "Gameplay started", + "functionType": "Action", + "name": "SetGameplayStarted", + "sentence": "Let CrazyGames know gameplay started", "events": [ { "type": "BuiltinCommonInstructions::Standard", @@ -63,15 +155,17 @@ ] } ], - "actions": [ + "actions": [], + "events": [ { - "type": { - "value": "CrazyGamesAdApi::InitializeSDK" - }, - "parameters": [ - "", + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "window.CrazyGames.SDK.game.gameplayStart();", "" - ] + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false } ] } @@ -80,23 +174,22 @@ "objectGroups": [] }, { - "description": "Intialize SDK.", - "fullName": "Intialize SDK", + "description": "Let CrazyGames know gameplay stopped.", + "fullName": "Gameplay stopped", "functionType": "Action", - "name": "InitializeSDK", - "private": true, - "sentence": "Intialize SDK", + "name": "SetGameplayStoped", + "sentence": "Let CrazyGames know gameplay stopped", "events": [ { "type": "BuiltinCommonInstructions::Standard", "conditions": [ { "type": { - "value": "SceneVariableAsBoolean" + "value": "CrazyGamesAdApi::IsSDKLoaded" }, "parameters": [ - "__CrazyGamesExtension.sdkInitialized", - "False" + "", + "" ] } ], @@ -105,13 +198,8 @@ { "type": "BuiltinCommonInstructions::JsCode", "inlineCode": [ - "try {", - " const crazysdk = window.CrazyGames.CrazySDK.getInstance();", - " crazysdk.init();", - " runtimeScene.getVariables().get(\"__CrazyGamesExtension\").getChild('sdkInitialized').setBoolean(true);", - "} catch(error) {", - " console.log(\"Unable to initialize SDK. Full error is:\", error);", - "}" + "window.CrazyGames.SDK.game.gameplayStop();", + "" ], "parameterObjects": "", "useStrict": true, @@ -124,61 +212,61 @@ "objectGroups": [] }, { - "description": "Load SDK.", - "fullName": "Load SDK", - "functionType": "Action", - "group": "Crazy Games", - "name": "LoadSDK", - "private": true, - "sentence": "Load SDK", - "events": [ - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "(()=>{var e={198:(e,t,n)=>{var r=1/0,i=9007199254740991,o=17976931348623157e292,a=NaN,s=\"[object Arguments]\",u=\"[object Map]\",c=\"[object Promise]\",l=\"[object Set]\",d=\"[object String]\",f=\"[object Symbol]\",h=\"[object WeakMap]\",p=\"[object DataView]\",y=/^\\s+|\\s+$/g,v=/^[-+]0x[0-9a-f]+$/i,b=/^0b[01]+$/i,g=/^\\[object .+?Constructor\\]$/,w=/^0o[0-7]+$/i,m=/^(?:0|[1-9]\\d*)$/,I=\"\\\\u0300-\\\\u036f\\\\ufe20-\\\\ufe23\",_=\"[\\\\ud800-\\\\udfff]\",S=\"[\"+I+\"\\\\u20d0-\\\\u20f0]\",E=\"\\\\ud83c[\\\\udffb-\\\\udfff]\",k=\"[^\\\\ud800-\\\\udfff]\",x=\"(?:\\\\ud83c[\\\\udde6-\\\\uddff]){2}\",T=\"[\\\\ud800-\\\\udbff][\\\\udc00-\\\\udfff]\",A=\"(?:\"+S+\"|\"+E+\")\"+\"?\",C=\"[\\\\ufe0e\\\\ufe0f]?\",O=C+A+(\"(?:\\\\u200d(?:\"+[k,x,T].join(\"|\")+\")\"+C+A+\")*\"),L=\"(?:\"+[k+S+\"?\",S,x,T,_].join(\"|\")+\")\",j=RegExp(E+\"(?=\"+E+\")|\"+L+O,\"g\"),D=RegExp(\"[\\\\u200d\\\\ud800-\\\\udfff\\\\u0300-\\\\u036f\\\\ufe20-\\\\ufe23\\\\u20d0-\\\\u20f0\\\\ufe0e\\\\ufe0f]\"),q=parseInt,z=\"object\"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,B=\"object\"==typeof self&&self&&self.Object===Object&&self,P=z||B||Function(\"return this\")();function M(e,t){return function(e,t){for(var n=-1,r=e?e.length:0,i=Array(r);++n-1&&e%1==0&&e=s?i:s)),t=i);++h-1&&e%1==0&&e<=i}(e.length)&&!xe(e)}function xe(e){var t=Te(e)?H.call(e):\"\";return\"[object Function]\"==t||\"[object GeneratorFunction]\"==t}function Te(e){var t=typeof e;return!!e&&(\"object\"==t||\"function\"==t)}function Ae(e){return!!e&&\"object\"==typeof e}function Ce(e){return e?M(e,function(e){return ke(e)?ye(e):be(e)}(e)):[]}e.exports=function(e){return Se(e,4294967295)}},807:function(e,t,n){\"use strict\";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=t.width&&e.height>=t.height}));n?t.push({containerId:e.id,size:\"\".concat(n.width,\"x\").concat(n.height)}):(0,c.debug)(\"No available banner size has been found for container \".concat(e.id))})),t},e.prototype.initEventCallback=function(e){this.initState===u.INITIALIZED&&e({userInfo:this.userInfo})},e.prototype.callListeners=function(e,t){(this.eventListeners[e]||[]).forEach((function(e){return e(t)}))},e.prototype.isValidCrazyEvent=function(e){switch(e){case\"adStarted\":case\"adFinished\":case\"adError\":case\"adblockDetectionExecuted\":case\"bannerRendered\":case\"bannerError\":case\"requestBanner\":case\"initialized\":return!0;default:return!1}},e.prototype.renderFakeBanner=function(e){var t=e.size.split(\"x\"),n=t[0],r=t[1],i=document.getElementById(e.containerId);if(i){i.innerHTML=\"\";var o=document.createElement(\"img\");o.setAttribute(\"src\",\"\".concat(\"https://images.crazygames.com/crazygames-sdk/\").concat(e.size,\".png\")),o.setAttribute(\"width\",\"\".concat(n,\"px\")),o.setAttribute(\"height\",\"\".concat(r,\"px\")),i.appendChild(o),i.style.backgroundColor=\"rgb(191, 173, 255, 0.25)\"}},e}();t.default=h},883:function(e,t,n){\"use strict\";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Class extends value \"+String(t)+\" is not a constructor or null\");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!(\"get\"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,\"default\",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)\"default\"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return a(t,e),t},u=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},c=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},\"function\"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError(\"Generator is already executing.\");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&((0,f.debug)(\"Valid banners\",e),(o=this.queuedBanners).push.apply(o,t),this.postMessage(\"requestBanner\",t)),[2]}}))}))},t.prototype.requestResponsiveBanner=function(e){return u(this,void 0,void 0,(function(){var t,n;return c(this,(function(r){switch(r.label){case 0:return[4,this.ensureInit(!0)];case 1:return r.sent(),(0,f.debug)(\"Requesting responsive banner to gameframe\",e),[4,this.checkBannerContainers(e,!0)];case 2:return(t=r.sent()).length>0&&((0,f.debug)(\"Valid containers\",t),(n=this.queuedBanners).push.apply(n,this.getBannerForContainers(t)),this.postMessage(\"requestResponsiveBanner\",t)),[2]}}))}))},t.prototype.clearBanner=function(e){var t=document.querySelector(\"#\".concat(e));if(t){for(;t.firstChild;)t.removeChild(t.firstChild);this.inGameRenderedBannerIds.delete(e)}},t.prototype.clearAllBanners=function(){var e=this;Array.from(this.inGameRenderedBannerIds.values()).forEach((function(t){e.clearBanner(t)}))},t.prototype.inviteLink=function(t){void 0===t&&(t={});var n=e.prototype.inviteLink.call(this,t);return this.postMessage(\"inviteUrl\",{inviteUrl:n}),n},t.prototype.happytime=function(){return u(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return(0,f.debug)(\"Requesting happytime\"),[4,this.ensureInit()];case 1:return e.sent(),this.postMessage(\"happytime\",{}),[2]}}))}))},t.prototype.gameplayStart=function(){return u(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return(0,f.debug)(\"Requesting gameplay start\"),[4,this.ensureInit()];case 1:return e.sent(),this.postMessage(\"gameplayStart\",{}),[2]}}))}))},t.prototype.gameplayStop=function(){return u(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return(0,f.debug)(\"Requesting gameplay stop\"),[4,this.ensureInit()];case 1:return e.sent(),this.postMessage(\"gameplayStop\",{}),[2]}}))}))},t.prototype.sdkGameLoadingStart=function(){return u(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return(0,f.debug)(\"Requesting start of game loading from sdk\"),[4,this.ensureInit()];case 1:return e.sent(),this.postMessage(\"sdkGameLoadingStart\",{}),[2]}}))}))},t.prototype.sdkGameLoadingStop=function(){return u(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return(0,f.debug)(\"Requesting stop of game loading from sdk\"),[4,this.ensureInit()];case 1:return e.sent(),this.postMessage(\"sdkGameLoadingStop\",{}),[2]}}))}))},t.prototype.sendInit=function(){var e={type:\"init\",data:{version:\"1.30.0\",sdkType:\"js\"}};window.parent.postMessage(e,\"*\"),window.parent.parent.postMessage(e,\"*\"),window.parent.parent.parent.postMessage(e,\"*\")},t.prototype.registerDefaultListeners=function(){var e=this;(0,f.debug)(\"Registering default listeners\"),this.addEventListener(\"adFinished\",(function(){e.requestInProgress=!1})),this.addEventListener(\"adError\",(function(){e.requestInProgress=!1})),this.addEventListener(\"adblockDetectionExecuted\",(function(t){e.adblockDetectionExecuted=!0;var n=t.hasAdblock;e.hasAdblock=!!n})),this.addEventListener(\"bannerError\",(function(e){(0,f.debug)(e.error,e.containerId)})),this.addEventListener(\"bannerRendered\",(function(t){e.inGameRenderedBannerIds.add(t.containerId),(0,f.debug)(\"Banner rendered for container \".concat(t.containerId))})),this.addEventListener(\"requestBanner\",(function(t){return u(e,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return(0,f.debug)(\"Banner request answer from gameframe received\",t.request),this.buildBannerRequestCallback(t.request),[4,(0,d.requestInGameBanner)(t.request)];case 1:return e.sent(),[2]}}))}))}))},t.prototype.buildBannerRequestCallback=function(e){var t=this;e.options.banner={callback:function(e){if(e.empty){if(t.useTestAds){var n=t.queuedBanners.find((function(t){return t.containerId===e.code}));return void(n&&(t.renderFakeBanner(n),t.removeBannerFromQueue(e.code),t.callListeners(\"bannerRendered\",{containerId:e.code})))}var r=\"Sorry, no banner is available for the moment for \".concat(e.code,\", please retry\");t.callListeners(\"bannerError\",{containerId:e.code,error:r}),t.removeBannerFromQueue(e.code,r)}else t.removeBannerFromQueue(e.code),t.callListeners(\"bannerRendered\",{containerId:e.code})}}},t.prototype.removeBannerFromQueue=function(e,t){var n=this.queuedBanners.find((function(t){return t.containerId!==e}));if(this.queuedBanners=this.queuedBanners.filter((function(t){return t.containerId!==e})),n){var r=n.size.split(\"x\").map(parseInt),i=r[0],o=r[1];this.postMessage(\"bannerProcessed\",{containerId:n.containerId,width:i,height:o,error:t})}},t.prototype.registerMessageListener=function(){window.addEventListener(\"message\",this.receiveMessage,!1)},t.prototype.initializeReply=function(e){return u(this,void 0,void 0,(function(){return c(this,(function(t){return e&&void 0!==e.debug&&(0,f.forceDebug)(e.debug),(0,f.debug)(\"Initialize reply received from gameframe\",e),this.initState===l.INIT_STATE.INITIALIZED||(e&&(this.gameLink=e.gameLink,this.rafvertizingUrl=e.rafvertizingUrl,this.useTestAds=e.useTestAds,this.userInfo=e.userInfo,this.disableBannerCheck=e.disableBannerCheck||!1),this.initState=l.INIT_STATE.INITIALIZED,this.initCallbacks.length>0&&((0,f.debug)(\"Calling init callbacks\"),this.initCallbacks.forEach((function(e){return e()})),this.initCallbacks=[]),this.callListeners(\"initialized\",{userInfo:this.userInfo})),[2]}))}))},t.prototype.ensureInit=function(e){return void 0===e&&(e=!1),u(this,void 0,void 0,(function(){var t=this;return c(this,(function(n){return this.initState===l.INIT_STATE.INITIALIZED?e?[2,(0,d.loadCrazyAdsIfNeeded)(this.rafvertizingUrl)]:[2,Promise.resolve()]:(this.init(),[2,new Promise((function(n){t.initCallbacks.push((function(){return u(t,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return e?[3,1]:(n(),[3,3]);case 1:return[4,(0,d.loadCrazyAdsIfNeeded)(this.rafvertizingUrl)];case 2:t.sent(),n(),t.label=3;case 3:return[2]}}))}))}))}))])}))}))},t.prototype.postMessage=function(e,t){this.gfWindow?this.gfWindow.postMessage({type:e,data:t},\"*\"):(0,f.debug)(\"CrazyGames gameframe hasn't been detected\")},t.prototype.isValidCrazyEvent=function(e){switch(e){case\"adStarted\":case\"adFinished\":case\"adError\":case\"adblockDetectionExecuted\":case\"bannerRendered\":case\"bannerError\":case\"requestBanner\":case\"initialized\":return!0;default:return!1}},t}(l.default);t.default=h},56:function(e,t,n){\"use strict\";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Class extends value \"+String(t)+\" is not a constructor or null\");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!(\"get\"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,\"default\",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)\"default\"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return a(t,e),t},u=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},c=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},\"function\"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError(\"Generator is already executing.\");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&((0,d.debug)(\"Valid banners\",t),this.renderFakeBanners(t)),[2]}}))}))},t.prototype.requestResponsiveBanner=function(e){return u(this,void 0,void 0,(function(){var t;return c(this,(function(n){switch(n.label){case 0:return(0,d.debug)(\"Requesting responsive banner\",e),[4,this.checkBannerContainers(e,!0)];case 1:return t=n.sent(),this.renderFakeBanners(this.getBannerForContainers(t)),[2]}}))}))},t.prototype.ensureInit=function(e){return void 0===e&&(e=!1),u(this,void 0,void 0,(function(){return c(this,(function(e){return[2]}))}))},t.prototype.initEventCallback=function(e){(0,d.debug)(\"Cannot get user info outside of CrazyGames\"),this.initState===l.INIT_STATE.INITIALIZED&&e({userInfo:{browser:{name:\"Chrome\",version:\"89.0.4389.82\"},countryCode:\"FR\",os:{name:\"Windows\",version:\"10\"}}})},t.prototype.renderFakeBanners=function(e){var t=this;e.forEach((function(e){t.renderFakeBanner(e)}))},t.prototype.renderFakeAd=function(e){var t=this;(0,d.debug)(\"requesting \".concat(e,\" ad\")),this.requestInProgress=!0,this.showOverlay(),this.overlay.innerHTML=\"

A \".concat(e,\" ad would appear here

\"),this.callListeners(\"adStarted\",{}),window.setTimeout((function(){t.requestInProgress=!1,t.callListeners(\"adFinished\",{}),t.hideOverlay()}),this.adDurationInMs)},t.prototype.showOverlay=function(){this.overlay.style.display=\"flex\"},t.prototype.hideOverlay=function(){this.overlay.style.display=\"none\",this.overlay.innerHTML=\"\"},t.prototype.createOverlayStyle=function(){var e={position:\"fixed\",display:\"none\",width:\"100%\",height:\"100%\",top:\"0\",left:\"0\",right:\"0\",bottom:\"0\",\"align-items\":\"center\",\"justify-content\":\"center\",\"background-color\":\"rgba(0,0,0,0.5)\",\"z-index\":\"10000\"};for(var t in e)this.overlay.style[t]=e[t]},t.prototype.clearBanner=function(e){(0,d.debug)(\"clearBanner \".concat(e))},t.prototype.clearAllBanners=function(){(0,d.debug)(\"clearAllBanners\")},t}(l.default);t.default=f},675:function(e,t,n){\"use strict\";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Class extends value \"+String(t)+\" is not a constructor or null\");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!(\"get\"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,\"default\",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)\"default\"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return a(t,e),t},u=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},c=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},\"function\"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError(\"Generator is already executing.\");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0?console.log(\"[JS-SDK] \".concat(e),t):console.log(\"[JS-SDK] \".concat(e)))}function f(e){return decodeURIComponent(window.location.search.replace(new RegExp(\"^(?:.*[&\\\\?]\"+encodeURIComponent(e).replace(/[\\.\\+\\*]/g,\"\\\\$&\")+\"(?:\\\\=([^&]*))?)?.*$\",\"i\"),\"$1\"))}t.forceDebug=function(e){i=e},t.debug=d,t.CrazyAdTypeMap={midgame:\"midgame\",rewarded:\"rewarded\"},t.CrazyEventTypeMap={adStarted:\"adStarted\",adFinished:\"adFinished\",adError:\"adError\",adblockDetectionExecuted:\"adblockDetectionExecuted\"},window.CrazyGames={CrazySDK:l,CrazyAdType:t.CrazyAdTypeMap,CrazyEventType:t.CrazyEventTypeMap},o=\"\\n.crazy-banner-container {\\n display: flex;\\n align-items: center;\\n justify-content: center;\\n}\\n\",(a=document.createElement(\"style\")).textContent=o,document.head.append(a),t.default=s.default},378:function(e,t){\"use strict\";var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},r=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},\"function\"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError(\"Generator is already executing.\");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1].95,size:{width:Math.ceil(i.boundingClientRect.width),height:Math.ceil(i.boundingClientRect.height)}}),r.disconnect()}));r.observe(e)}))]}))}))}t.checkContainerVisible=function(e,t,o,a){return n(this,void 0,void 0,(function(){var n,s,u;return r(this,(function(r){switch(r.label){case 0:return(n=document.getElementById(e))?[4,i(n,a)]:(u=\"The container \".concat(e,\" is not present on the page\"),t(u),[2,{isVisible:!1,size:{width:0,height:0}}]);case 1:return(s=r.sent()).isVisible?!o||0!==s.size.width&&0!==s.size.height?(n.classList.add(\"crazy-banner-container\"),[2,s]):(u=\"The container \".concat(e,\" must have a non-null width and height to render a responsive banner.\"),t(u),[2,{isVisible:!1,size:{width:0,height:0}}]):(u=\"The container \".concat(e,\" is not entirely visible on the page\"),t(u),[2,s])}}))}))}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}n.g=function(){if(\"object\"==typeof globalThis)return globalThis;try{return this||new Function(\"return this\")()}catch(e){if(\"object\"==typeof window)return window}}();n(607)})();", - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": false - } - ], - "parameters": [], - "objectGroups": [] - }, - { - "description": "Display Crazy Game Ad.", - "fullName": "Display Crazy Game Ad", + "description": "Display a video ad. The game is automatically mute while the video is playing.", + "fullName": "Display video ad", "functionType": "Action", - "group": "Crazy Games", "name": "DisplayCrazyGamesAd", - "sentence": "Display Crazy Game Ad Type _PARAM1_", + "sentence": "Display _PARAM1_ video ad", "events": [ { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "try {", - " const crazysdk = window.CrazyGames.CrazySDK.getInstance();", - " const AdType = eventsFunctionContext.getArgument(\"AdType\").toString();", - "", - " crazysdk.requestAd(AdType);", - " ", - " runtimeScene.getVariables().get(\"__CrazyGamesExtension\").getChild('adFinished').setBoolean(false);", - " runtimeScene.getVariables().get(\"__CrazyGamesExtension\").getChild('adError').setBoolean(false); ", - " ", - " crazysdk.addEventListener(\"adFinished\", function() {", - " runtimeScene.getVariables().get(\"__CrazyGamesExtension\").getChild('adFinished').setBoolean(true);", - " });", - " crazysdk.addEventListener(\"adError\", function(error) {", - " runtimeScene.getVariables().get(\"__CrazyGamesExtension\").getChild('adError').setBoolean(true);", - " console.log({error});", - " });", - "", - "} catch(error) {", - " runtimeScene.getVariables().get(\"__CrazyGamesExtension\").getChild('adError').setBoolean(true);", - " console.log(\"Unable to display ad. Full error is:\", error);", - "}" + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "CrazyGamesAdApi::IsSDKLoaded" + }, + "parameters": [ + "", + "" + ] + } ], - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": true + "actions": [], + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const logger = new gdjs.Logger(\"CrazyGames SDK\");", + "", + "const adType = eventsFunctionContext.getArgument(\"AdType\");", + "", + "const volume = runtimeScene.getSoundManager().getGlobalVolume();", + "window.CrazyGames.SDK.ad.requestAd(adType, {", + " adStarted: () => {", + " gdjs._crazyGamesExtension.isPlayingVideoAd = true;", + " runtimeScene.getSoundManager().setGlobalVolume(0);", + " },", + " adFinished: () => {", + " gdjs._crazyGamesExtension.hasVideoAdJustFinishedPlaying = true;", + " gdjs._crazyGamesExtension.isPlayingVideoAd = false;", + " if (runtimeScene.getSoundManager().getGlobalVolume() === 0) {", + " runtimeScene.getSoundManager().setGlobalVolume(volume);", + " }", + " },", + " adError: (error, errorData) => {", + " gdjs._crazyGamesExtension.isPlayingVideoAd = false;", + " if (runtimeScene.getSoundManager().getGlobalVolume() === 0) {", + " runtimeScene.getSoundManager().setGlobalVolume(volume);", + " }", + " logger.error(\"Error midgame ad (callback)\", error, errorData);", + " },", + "});" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ] } ], "parameters": [ @@ -192,50 +280,36 @@ "objectGroups": [] }, { - "description": "Check if Ad Finished playing.", - "fullName": "Check if Ad Finished playing", + "description": "Checks if a video ad just finished playing successfully.", + "fullName": "Video ad just finished playing", "functionType": "Condition", - "group": "Crazy Games", "name": "AdFinishedPlaying", - "sentence": "Ad is finished playing?", + "sentence": "Video ad just finished playing", "events": [ { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnBoolean" - }, - "parameters": [ - "" - ] - } - ] - }, + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": "eventsFunctionContext.returnValue = gdjs._crazyGamesExtension.hasVideoAdJustFinishedPlaying;", + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "Checks if a video ad is playing.", + "fullName": "Video ad is playing", + "functionType": "Condition", + "name": "IsVideoAdPlaying", + "sentence": "Video ad is playing", + "events": [ { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SceneVariableAsBoolean" - }, - "parameters": [ - "__CrazyGamesExtension.adFinished", - "True" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetReturnBoolean" - }, - "parameters": [ - "True" - ] - } - ] + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": "eventsFunctionContext.returnValue = gdjs._crazyGamesExtension.isPlayingVideoAd;", + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false } ], "parameters": [], @@ -245,17 +319,39 @@ "description": "Check if Ad had an error.", "fullName": "Check if Ad had an error", "functionType": "Condition", - "group": "Crazy Games", "name": "AdHadAnError", + "private": true, "sentence": "Ad had an error?", + "events": [], + "parameters": [], + "objectGroups": [] + }, + { + "async": true, + "description": "Generate an invite link.", + "fullName": "Generate an invite link", + "functionType": "Action", + "name": "GenerateInviteLink", + "sentence": "Generate an invite link for _PARAM1_", "events": [ { "type": "BuiltinCommonInstructions::Standard", - "conditions": [], + "conditions": [ + { + "type": { + "inverted": true, + "value": "CrazyGamesAdApi::IsSDKLoaded" + }, + "parameters": [ + "", + "" + ] + } + ], "actions": [ { "type": { - "value": "SetReturnBoolean" + "value": "BuiltinAsync::ResolveAsyncEventsFunction" }, "parameters": [ "" @@ -268,48 +364,62 @@ "conditions": [ { "type": { - "value": "SceneVariableAsBoolean" + "value": "CrazyGamesAdApi::IsSDKLoaded" }, "parameters": [ - "__CrazyGamesExtension.adError", - "True" + "", + "" ] } ], - "actions": [ + "actions": [], + "events": [ { - "type": { - "value": "SetReturnBoolean" - }, - "parameters": [ - "True" - ] + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const roomId = eventsFunctionContext.getArgument(\"RoomId\");", + "", + "const logger = new gdjs.Logger(\"CrazyGames SDK\");", + "window.CrazyGames.SDK.game.inviteLink(", + " { roomId },", + " (error, link) => {", + " if (error) {", + " logger.error(\"Invite link error.\", error);", + " } else {", + " gdjs._crazyGamesExtension.links.set(roomId, link);", + " eventsFunctionContext.task.resolve();", + " }", + "}", + ");" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true } ] } ], - "parameters": [], + "parameters": [ + { + "description": "Room id", + "name": "RoomId", + "type": "string" + } + ], "objectGroups": [] }, { - "description": "Returns an invite link.", - "fullName": "Returns an invite link", - "functionType": "ExpressionAndCondition", + "description": "Return an invite link.", + "fullName": "Invite link", + "functionType": "StringExpression", "name": "InviteLink", - "sentence": "Returns an invite link _PARAM1_", + "sentence": "", "events": [ { "type": "BuiltinCommonInstructions::JsCode", "inlineCode": [ - "try {", - " const crazysdk = window.CrazyGames.CrazySDK.getInstance();", - " const roomId = eventsFunctionContext.getArgument(\"RoomId\");", - " const linkToShare = crazysdk.inviteLink({ roomId: roomId });", - "", - " eventsFunctionContext.returnValue = linkToShare;", - "} catch(error) {", - " console.log(\"Unable to create an invite link. Full error is:\", error);", - "}" + "const roomId = eventsFunctionContext.getArgument(\"RoomId\");\r", + "eventsFunctionContext.returnValue = gdjs._crazyGamesExtension.links.get(roomId) || \"\";" ], "parameterObjects": "", "useStrict": true, @@ -321,7 +431,7 @@ }, "parameters": [ { - "description": "RoomId", + "description": "Room id", "name": "RoomId", "type": "string" } @@ -329,92 +439,66 @@ "objectGroups": [] }, { - "description": "Check if CrazyGame SDK is loaded.", - "fullName": "Check if CrazyGame SDK is loaded", - "functionType": "Condition", - "name": "IsSDKLoaded", - "sentence": "Is CrazyGame SDK loaded?", - "events": [ - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "eventsFunctionContext.returnValue = (CrazyGames != undefined);", - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": false - } - ], - "parameters": [], - "objectGroups": [] - }, - { - "description": "Display CrazyGames Happy Time.", - "fullName": "Display CrazyGames Happy Time", + "description": "Display CrazyGames Happy Time. The celebration should remain a special moment.", + "fullName": "Display happy time", "functionType": "Action", "name": "DisplayHappyTime", - "sentence": "Display CrazyGames Happy Time", + "sentence": "Display happy time", "events": [ { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "try {", - " const crazysdk = window.CrazyGames.CrazySDK.getInstance();", - " // Player beats a boss, reaches a high score, etc.", - " crazysdk.happytime();", - "} catch(error) {", - " console.log(\"Unable to display happytime. Full error is:\", error);", - "}" + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "CrazyGamesAdApi::IsSDKLoaded" + }, + "parameters": [ + "", + "" + ] + } ], - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": false + "actions": [], + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": "window.CrazyGames.SDK.game.happytime();", + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ] } ], "parameters": [], "objectGroups": [] }, { + "async": true, "description": "Scan for adblockers.", "fullName": "Scan for adblockers", "functionType": "Action", "name": "ScanForAdBlockers", "sentence": "Scan for adblockers", - "events": [ - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "try {", - " function adblockDetection(event) {", - " runtimeScene.getVariables().get(\"__CrazyGamesExtension\").getChild(\"adBlocker\").setBoolean(!!event.hasAdblock);", - " }", - "", - " const crazysdk = window.CrazyGames.CrazySDK.getInstance();", - " crazysdk.addEventListener(\"adblockDetectionExecuted\", adblockDetection);", - "} catch(error) {", - " console.log(\"Unable to scan adblockers. Full error is:\", error);", - "}" - ], - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": true - } - ], - "parameters": [], - "objectGroups": [] - }, - { - "description": "Check if user is using an ad blocker.", - "fullName": "Check if user is using an ad blocker", - "functionType": "Condition", - "name": "IsAdBlocked", - "sentence": "Is user using ad block?", "events": [ { "type": "BuiltinCommonInstructions::Standard", - "conditions": [], + "conditions": [ + { + "type": { + "inverted": true, + "value": "CrazyGamesAdApi::IsSDKLoaded" + }, + "parameters": [ + "", + "" + ] + } + ], "actions": [ { "type": { - "value": "SetReturnBoolean" + "value": "BuiltinAsync::ResolveAsyncEventsFunction" }, "parameters": [ "" @@ -427,30 +511,58 @@ "conditions": [ { "type": { - "value": "SceneVariableAsBoolean" + "value": "CrazyGamesAdApi::IsSDKLoaded" }, "parameters": [ - "__CrazyGamesExtension.adBlocker", - "True" + "", + "" ] } ], - "actions": [ + "actions": [], + "events": [ { - "type": { - "value": "SetReturnBoolean" - }, - "parameters": [ - "True" - ] + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const logger = new gdjs.Logger(\"CrazyGames SDK\");", + "window.CrazyGames.SDK.ad.hasAdblock((error, result) => {", + " if (error) {", + " logger.error(\"Unable to scan adblockers.\", error);", + " } else {", + " gdjs._crazyGamesExtension.isAdBlockerDetected = result;", + " eventsFunctionContext.task.resolve();", + " }", + "});" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true } ] } ], "parameters": [], "objectGroups": [] + }, + { + "description": "Check if user is using an ad blocker. This condition is always false before the \"Scan for adblockers\" is called.", + "fullName": "Ad blocker is detected", + "functionType": "Condition", + "name": "IsAdBlocked", + "sentence": "Ad blocker is detected", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": "eventsFunctionContext.returnValue = gdjs._crazyGamesExtension.isAdBlockerDetected;", + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] } ], "eventsBasedBehaviors": [], "eventsBasedObjects": [] -} \ No newline at end of file +} diff --git a/scripts/lib/ExtensionsValidatorExceptions.js b/scripts/lib/ExtensionsValidatorExceptions.js index c67d67537..a8154089e 100644 --- a/scripts/lib/ExtensionsValidatorExceptions.js +++ b/scripts/lib/ExtensionsValidatorExceptions.js @@ -183,6 +183,12 @@ const extensionsAllowedProperties = { runtimeSceneAllowedProperties: [], javaScriptObjectAllowedProperties: [], }, + CrazyGamesAdApi: { + gdjsAllowedProperties: ['_crazyGamesExtension'], + gdjsEvtToolsAllowedProperties: [], + runtimeSceneAllowedProperties: ['getSoundManager'], + javaScriptObjectAllowedProperties: [], + }, CurvedMovement: { gdjsAllowedProperties: [ '__curvedMovementExtension',