diff --git a/api/map/action.js b/api/map/action.js index d47b8ee..93587d6 100644 --- a/api/map/action.js +++ b/api/map/action.js @@ -45,6 +45,11 @@ async function validateMap(name, data, description_short, description_long, edit description_short = description_short.trim(); description_long = description_long.trim(); + // name cannot include crazygamesdue to a url detection bug + if(name.toLowerCase().includes('crazygames')) { + return 'Name cannot include "CrazyGames"'; + } + // validate name if(typeof name !== 'string' || name.length < mapConst.MIN_NAME_LENGTH || name.length > mapConst.MAX_NAME_LENGTH) { // return res.status(400).json({ message: `Name must be between ${mapConst.MIN_NAME_LENGTH} and ${mapConst.MAX_NAME_LENGTH} characters` }); @@ -74,6 +79,9 @@ async function validateMap(name, data, description_short, description_long, edit // return res.status(400).json({ message: 'Please choose a different name' }); return 'Please choose a different name'; } + if(slug.toLowerCase().includes('crazygames') ) { + return 'Name cannot include "CrazyGames"'; + } // validate data const locationsData = parseMapData(data); diff --git a/components/gameUI.js b/components/gameUI.js index f743b35..837e749 100644 --- a/components/gameUI.js +++ b/components/gameUI.js @@ -24,7 +24,7 @@ import HealthBar from "./duelHealthbar"; const MapWidget = dynamic(() => import("../components/Map"), { ssr: false }); -export default function GameUI({ miniMapShown, setMiniMapShown, singlePlayerRound, setSinglePlayerRound, showDiscordModal, setShowDiscordModal, inCrazyGames, showPanoOnResult, setShowPanoOnResult, countryGuesserCorrect, setCountryGuesserCorrect, otherOptions, onboarding, setOnboarding, countryGuesser, options, timeOffset, ws, multiplayerState, backBtnPressed, setMultiplayerState, countryStreak, setCountryStreak, loading, setLoading, session, gameOptionsModalShown, setGameOptionsModalShown, latLong, streetViewShown, setStreetViewShown, loadLocation, gameOptions, setGameOptions, showAnswer, setShowAnswer, pinPoint, setPinPoint, hintShown, setHintShown, xpEarned, setXpEarned, showCountryButtons, setShowCountryButtons }) { +export default function GameUI({ inCoolMathGames, miniMapShown, setMiniMapShown, singlePlayerRound, setSinglePlayerRound, showDiscordModal, setShowDiscordModal, inCrazyGames, showPanoOnResult, setShowPanoOnResult, countryGuesserCorrect, setCountryGuesserCorrect, otherOptions, onboarding, setOnboarding, countryGuesser, options, timeOffset, ws, multiplayerState, backBtnPressed, setMultiplayerState, countryStreak, setCountryStreak, loading, setLoading, session, gameOptionsModalShown, setGameOptionsModalShown, latLong, streetViewShown, setStreetViewShown, loadLocation, gameOptions, setGameOptions, showAnswer, setShowAnswer, pinPoint, setPinPoint, hintShown, setHintShown, xpEarned, setXpEarned, showCountryButtons, setShowCountryButtons }) { const { t: text } = useTranslation("common"); const [showStreakAdBanner, setShowStreakAdBanner] = useState(false); @@ -101,6 +101,15 @@ export default function GameUI({ miniMapShown, setMiniMapShown, singlePlayerRoun sendEvent('discord_modal_shown') } else console.log("Not showing discord modal, waiting for "+(600000 - (Date.now() - loadTime))+"ms") } + if(process.env.NEXT_PUBLIC_COOLMATH === "true") { + try { + console.log("Sending start event to CoolMathGames") + window.parent.postMessage({'cm_game_event': true, 'cm_game_evt' : 'start', 'cm_game_lvl': + "singleplayer"}, '*'); + }catch(e) { + console.log("Failed sending start event to CoolMathGames", e) + } + } // this is now disabled due to issues with afterAd() not being called / next round button not working if(false && window.show_videoad && !session?.token?.supporter) { window.show_videoad((state) =>{ @@ -382,7 +391,7 @@ export default function GameUI({ miniMapShown, setMiniMapShown, singlePlayerRoun setLostCountryStreak(countryStreak); // remove rewarded ads temporarily - if(countryStreak > 0 && window.adBreak && !inCrazyGames) { + if(countryStreak > 0 && window.adBreak && !inCrazyGames && !inCoolMathGames) { console.log("requesting reward ad") window.adBreak({ type: 'reward', // rewarded ad @@ -445,7 +454,7 @@ export default function GameUI({ miniMapShown, setMiniMapShown, singlePlayerRoun return (
-{ !onboarding && !inCrazyGames && (!session?.token?.supporter) && ( +{ !onboarding && !inCrazyGames && !inCoolMathGames && (!session?.token?.supporter) && (
diff --git a/components/headContent.js b/components/headContent.js index 0d48940..a1a945a 100644 --- a/components/headContent.js +++ b/components/headContent.js @@ -2,9 +2,10 @@ import Head from "next/head"; import Script from "next/script"; import { useEffect } from "react"; -export default function HeadContent({text}) { +export default function HeadContent({text,inCoolMathGames}) { useEffect(() => { - if (!window.location.search.includes("crazygames") && !process.env.NEXT_PUBLIC_POKI) { + if (!window.location.search.includes("crazygames") && !process.env.NEXT_PUBLIC_POKI && + !process.env.NEXT_PUBLIC_COOLMATH) { const script = document.createElement('script'); script.src = "https://api.adinplay.com/libs/aiptag/pub/SWT/worldguessr.com/tag.min.js"; script.async = true; @@ -38,7 +39,31 @@ export default function HeadContent({text}) { return () => { document.body.removeChild(script); } - } else if(process.env.NEXT_PUBLIC_POKI === "true") { + } else if(process.env.NEXT_PUBLIC_COOLMATH === "true") { + /* +*/ + + const script = document.createElement('script'); + script.src = "https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"; + script.async = false; + document.body.appendChild(script); + + const script2 = document.createElement('script'); + script2.src = "https://www.coolmathgames.com/sites/default/files/cmg-ads.js"; + script2.async = false; + document.body.appendChild(script2); + + return () => { + document.body.removeChild(script); + document.body.removeChild(script2); + } + + }else if(process.env.NEXT_PUBLIC_POKI === "true") { // const script = document.createElement('script'); script.src = "https://game-cdn.poki.com/scripts/v2/poki-sdk.js"; @@ -57,7 +82,8 @@ export default function HeadContent({text}) { return ( - {text("tabTitle")} + { inCoolMathGames ? "WorldGuessr - Play it now at CoolmathGames.com" : + text("tabTitle") } diff --git a/components/home.js b/components/home.js index 6da2804..6074dd1 100644 --- a/components/home.js +++ b/components/home.js @@ -410,6 +410,41 @@ statsRef.current = stats; const [showDiscordModal, setShowDiscordModal] = useState(false); const [singlePlayerRound, setSinglePlayerRound] = useState(null); const [partyModalShown, setPartyModalShown] = useState(false); + + const [inCoolMathGames, setInCoolMathGames] = useState(false); + const [coolmathSplash, setCoolmathSplash] = useState(null); + + // check if ?coolmath=true + useEffect(() => { + if(process.env.NEXT_PUBLIC_COOLMATH === "true") { + setInCoolMathGames(true); + window.lastCoolmathAd =Date.now(); + + setCoolmathSplash(0); + let interval = setInterval(() => { + setCoolmathSplash((prev) => { + if(prev >= 1) { + clearInterval(interval); + interval = setInterval(() => { + setCoolmathSplash((prev) => { + if(prev <= 0) { + clearInterval(interval); + return null; + } + return prev - 0.1 + }) + }, 100) + } + return prev + 0.1 + }) + }, 100) + + return () => { + clearInterval(interval); + } + } + }, []) + useEffect(() => { if(screen === "singleplayer") { // start the single player game @@ -1485,7 +1520,29 @@ setShowCountryButtons(false) adStarted: () => console.log("Start midgame ad"), }; window.CrazyGames.SDK.ad.requestAd("midgame", callbacks); - } catch(e) {} + } catch(e) { + console.log("error requesting midgame ad", e) + adFinished() + } + } else if(process.env.NEXT_PUBLIC_COOLMATH === "true" && Date.now() - window.lastCoolmathAd > 120000) { + try { + window.lastCoolmathAd = Date.now(); + function onEnd() { + adFinished() + console.log("End midgame ad") + document.removeEventListener("adBreakComplete", onEnd); + } + function onStart() { + console.log("Start midgame ad") + document.removeEventListener("adBreakStart", onStart); + } + window.cmgAdBreak(); + document.addEventListener("adBreakStart", onStart); + document.addEventListener("adBreakComplete", onEnd); + } catch(e) { + console.log("error requesting midgame ad", e) + adFinished() + } } else { adFinished() } @@ -1792,7 +1849,7 @@ setShowCountryButtons(false) return ( <> - + @@ -1812,10 +1869,35 @@ setShowCountryButtons(false)
+{ typeof coolmathSplash === "number" && ( + // black background +
+
+ {/* image /coolmath-splash.png */} + + +
+
+ +)} + {screen === "home" && !mapModal && !merchModal && !friendsModal && !accountModalOpen && !leagueModal && (
- { !isApp && ( + { !isApp && !inCoolMathGames && ( <> @@ -1883,7 +1965,7 @@ setShowCountryButtons(false) - setFriendsModal(true)} loginQueued={loginQueued} setLoginQueued={setLoginQueued} inGame={multiplayerState?.inGame || screen === "singleplayer"} openAccountModal={() => setAccountModalOpen(true)} session={session} reloadBtnPressed={reloadBtnPressed} backBtnPressed={backBtnPressed} setGameOptionsModalShown={setGameOptionsModalShown} onNavbarPress={() => onNavbarLogoPress()} gameOptions={gameOptions} screen={screen} multiplayerState={multiplayerState} shown={!multiplayerState?.gameData?.public && !leagueModal} /> + setFriendsModal(true)} loginQueued={loginQueued} setLoginQueued={setLoginQueued} inGame={multiplayerState?.inGame || screen === "singleplayer"} openAccountModal={() => setAccountModalOpen(true)} session={session} reloadBtnPressed={reloadBtnPressed} backBtnPressed={backBtnPressed} setGameOptionsModalShown={setGameOptionsModalShown} onNavbarPress={() => onNavbarLogoPress()} gameOptions={gameOptions} screen={screen} multiplayerState={multiplayerState} shown={!multiplayerState?.gameData?.public && !leagueModal} /> {/* ELO/League button */} {screen === "home" && !mapModal && session && session?.token?.secret && ( )} - {!inGame && showAccBtn && ()} + {!inGame && showAccBtn && !inCoolMathGames && ()}
diff --git a/public/ads.txt b/public/ads.txt index 753d189..e6a3a7b 100644 --- a/public/ads.txt +++ b/public/ads.txt @@ -1,5 +1,18 @@ +#---------------------------------------------------------------------------- +# +# ___ ___ __| | ___ _ __ __ _ __ _ _ _| |_ __ _ _ __ ___ +# / __/ _ \ / _` |/ _ \ '__| / _` |/ _` | | | | __/ _` | '_ ` _ \ +# | (_| (_) | (_| | __/ | | (_| | (_| | |_| | || (_| | | | | | | +# \___\___/ \__,_|\___|_| \__, |\__,_|\__,_|\__\__,_|_| |_| |_| +# |___/ +# +# We make games +#---------------------------------------------------------------------------- + +google.com, pub-3340825671684972, DIRECT, f08c47fec0942fa0 + ################################## -# AdinPlay.com ads.txt - 2024-06-24 +# AdinPlay.com ads.txt - 2024-12-13 ################################## OWNERDOMAIN=swordbattle.io @@ -8,7 +21,6 @@ adinplay.com, SWT, DIRECT #Google google.com, pub-3282547114800347, RESELLER, f08c47fec0942fa0 -google.com, pub-3340825671684972, DIRECT, f08c47fec0942fa0 #Appnexus appnexus.com, 8631, RESELLER, f5ab79cb980f11d1 @@ -127,11 +139,11 @@ adyoulike.com,7463c359225e043c111036d7a29affa5,RESELLER minutemedia.com,01gya4708ddm,RESELLER visiblemeasures.com,1052,RESELLER undertone.com,4205,RESELLER,d954590d0cb265b9 -imds.tv,AM1601,RESELLER,ae6c32151e71f19d +admedia.com,AM1601,RESELLER,ae6c32151e71f19d triplelift.com,8472,DIRECT,6c33edb13117fd86 kargo.com,8824,RESELLER start.io,123111883,RESELLER - +connectad.io,455,RESELLER,85ac85a30c93b3e5 # 33Across rubiconproject.com, 16414, RESELLER, 0bfd66d529a55807 #33Across #hb #tag @@ -170,13 +182,8 @@ appnexus.com, 10617, RESELLER, f5ab79cb980f11d1 appnexus.com, 9393, RESELLER, f5ab79cb980f11d1 advertising.com, 25034, RESELLER sonobi.com, 783272317b, RESELLER, d1a215d9eb5aee9e -spotxchange.com, 85519, RESELLER, 7842df1d2fe2db34 indexexchange.com, 186684,RESELLER, 50b1c356f2c5c8fc -#SpotX -spotxchange.com, 267531, RESELLER, 7842df1d2fe2db34 -spotx.tv, 267531, RESELLER, 7842df1d2fe2db34 - #CPM appnexus.com, 9624, RESELLER, f5ab79cb980f11d1 adtech.com, 11506, RESELLER @@ -208,10 +215,6 @@ openx.com, 539625136, RESELLER, 6a698e2ec38604c6 smaato.com, 1100037086, RESELLER smaato.com, 1100000579, RESELLER sovrn.com, 249425, RESELLER, fafdf38b16bf6b2b -spotx.tv, 173175, RESELLER, 7842df1d2fe2db34 -spotx.tv, 173177, RESELLER, 7842df1d2fe2db34 -spotxchange.com, 173177, RESELLER, 7842df1d2fe2db34 -spotxchange.com, 173175, RESELLER, 7842df1d2fe2db34 openx.com, 541079309, RESELLER, 6a698e2ec38604c6 openx.com, 541166421, RESELLER, 6a698e2ec38604c6 contextweb.com, 562263, RESELLER, 89ff185a4c4e857c @@ -229,15 +232,11 @@ openx.com, 540634629, RESELLER, 6a698e2ec38604c6 pubmatic.com, 156715, RESELLER, 5d62403b186f2ace rubiconproject.com, 13762, RESELLER, 0bfd66d529a55807 smartadserver.com, 3490, RESELLER -spotx.tv, 141412, RESELLER, 7842df1d2fe2db34 -spotxchange.com, 141412, RESELLER, 7842df1d2fe2db34 springserve.com, 550, RESELLER, a24eb641fc82e93d beachfront.com, 4969, RESELLER, e2541279e8e2ca4d advertising.com, 26282, RESELLER pubmatic.com, 157310, RESELLER, 5d62403b186f2ace rhythmone.com, 2968119028, RESELLER, a670c89d4a324e47 -spotxchange.com, 239904, RESELLER, 7842df1d2fe2db34 -spotx.tv, 239904, RESELLER, 7842df1d2fe2db34 contextweb.com, 561910, RESELLER, 89ff185a4c4e857c openx.com, 540226160, RESELLER, 6a698e2ec38604c6 openx.com, 540255318, RESELLER, 6a698e2ec38604c6 @@ -251,8 +250,6 @@ vidoomy.com, 51019, RESELLER aol.com, 22762, RESELLER freewheel.tv, 872257, RESELLER openx.com, 540804929, RESELLER, 6a698e2ec38604c6 -spotx.tv, 218443, RESELLER, 7842df1d2fe2db34 -spotxchange.com, 218443, RESELLER, 7842df1d2fe2db34 emxdgt.com, 1495, RESELLER, 1e1d41537f7cad7f #Rubicon @@ -272,6 +269,26 @@ pubmatic.com, 158355, RESELLER, 5d62403b186f2ace appnexus.com, 9393, RESELLER, f5ab79cb980f11d1 #Video #Display appnexus.com, 11924, RESELLER, f5ab79cb980f11d1 +#Kueez +kueez.com, fe46d13305ce1b89f18a84c52275b7fe, direct +appnexus.com,8826,RESELLER +rubiconproject.com,16920,RESELLER +openx.com,557564833,RESELLER +lijit.com,407406,RESELLER +media.net,8cu4jtrf9,RESELLER +pubmatic.com,162110,RESELLER +sharethrough.com,n98xdzel,RESELLER +33across.com,0010b00002odu4haax,RESELLER +yieldmo.com,3133660606033240149,RESELLER +onetag.com,6e053d779444c00,RESELLER +video.unrulymedia.com,3486482593,RESELLER +sonobi.com,4c4fba1717,RESELLER +smartadserver.com,4288,RESELLER +zetaglobal.com,108,RESELLER +improvedigital.com,2106,RESELLER +loopme.com,11576,RESELLER +themediagrid.com,uot45z,RESELLER + #Aniview @@ -519,10 +536,6 @@ pubmatic.com, 160552, RESELLER, 5d62403b186f2ace # pubmatic.com, 159401, RESELLER, 5d62403b186f2ace # PubMatic_2_6&7 pubmatic.com, 163598, RESELLER, 5d62403b186f2ace # Pubmatic_OW richaudience.com, 1XvIoD5o0S, DIRECT # Rich Audience_0_6&7 -pubmatic.com, 81564, DIRECT, 5d62403b186f2ace # Rich Audience_0_6&7 -pubmatic.com, 156538, DIRECT, 5d62403b186f2ace # Rich Audience_0_6&7 -appnexus.com, 8233, DIRECT # Rich Audience_0_6&7 -rubiconproject.com, 13510, DIRECT # Rich Audience_0_6&7 risecodes.com, 5fa94677b2db6a00015b22a9, DIRECT # Rise pubmatic.com, 160295, RESELLER, 5d62403b186f2ace # Rise xandr.com, 14082, RESELLER # Rise @@ -651,6 +664,18 @@ betweendigital.com, 44808, RESELLER adyoulike.com, 53264963677efeda057eef7db2cb305f, RESELLER freewheel.tv,1577878,RESELLER freewheel.tv,1577888,RESELLER +dxkulture.com, 9533, DIRECT, 259726033fc4df0c +dxkulture.com, 0098, DIRECT, 259726033fc4df0c +adswizz.com,dxkulture,DIRECT +adswizz.com,651,DIRECT +pubmatic.com,164751,RESELLER,5d62403b186f2ace +rubiconproject.com,26094,DIRECT,0bfd66d529a55807 +zetaglobal.net,790,DIRECT +ssp.disqus.com,790,DIRECT +video.unrulymedia.com,946176315,RESELLER +video.unrulymedia.com, 347774562, RESELLER +rubiconproject.com, 15268, RESELLER, 0bfd66d529a55807 +pubmatic.com, 159277, RESELLER #AdaptMX @@ -728,9 +753,9 @@ sonobi.com, 3ee2ca3952, RESELLER, d1a215d9eb5aee9e #Rich Audience -richaudience.com, kWVs0vbyki, DIRECT +richaudience.com, kWVs0vbyki, RESELLER appnexus.com, 2928, DIRECT, f5ab79cb980f11d1 -appnexus.com, 8233, DIRECT, f5ab79cb980f11d1 +smartadserver.com, 1999, RESELLER, 060d053dcf45cbf3 #Ozone @@ -743,6 +768,22 @@ indexexchange.com, 206233, RESELLER, 50b1c356f2c5c8fc themediagrid.com, 1J3ZI6, DIRECT, 35d5010d7789b49d themediagrid.com, WF71T3, DIRECT, 35d5010d7789b49d +# OptiDigital +optidigital.com,p345,INTERMEDIATE +pubmatic.com,158939,RESELLER,5d62403b186f2ace +rubiconproject.com,20336,RESELLER,0bfd66d529a55807 +smartadserver.com,3379,RESELLER,060d053dcf45cbf3 +criteo.com,B-060926,RESELLER,9fac4a4a87c2a44f +themediagrid.com,3ETIX5,RESELLER,35d5010d7789b49d +triplelift.com,8183,RESELLER,6c33edb13117fd86 +appnexus.com,12190,RESELLER,f5ab79cb980f11d1 +onetag.com,806eabb849d0326,RESELLER +rtbhouse.com,mSu1piUSmB9TF4AQDGk4,RESELLER +33across.com,001Pg00000HMy0YIAT,RESELLER,bbea06d9c4d2853c +e-planning.net,a76893b96338e7e9,RESELLER,c1ba615865ed87b2 +appnexus.com,15941,RESELLER,f5ab79cb980f11d1 +video.unrulymedia.com,731539260,RESELLER + #Rise risecodes.com, 643813aab7212c00011c3f28, DIRECT pubmatic.com, 160295, RESELLER, 5d62403b186f2ace @@ -761,10 +802,10 @@ lijit.com, 405318, RESELLER, fafdf38b16bf6b2b themediagrid.com, 4DQHAP, RESELLER, 35d5010d7789b49d loopme.com, 11362, RESELLER, 6c8d5f95897a5a3b amxrtb.com, 105199691, RESELLER -freewheel.tv, 1590601, RESELLER -freewheel.tv, 1590606, RESELLER smartadserver.com, 4284, RESELLER adform.com, 3119, RESELLER, 9f5210a2f0999e32 +smaato.com, 1100057444, RESELLER, 07bcf65f187117b4 +adyoulike.com, 78afbc34fac571736717317117dfa247, RESELLER #Block blockthrough.com, 5130683165442048, DIRECT @@ -795,5 +836,5 @@ vidazoo.com, 655c85dc63ceeb606a0f365f, DIRECT, b6ada874b4d7d0b2 smartadserver.com, 3490, DIRECT ################################## -# AdinPlay.com ads.txt - 2024-06-24 +# AdinPlay.com ads.txt - 2024-12-13 ################################## \ No newline at end of file diff --git a/public/coolmath-splash.png b/public/coolmath-splash.png new file mode 100644 index 0000000..73d812d Binary files /dev/null and b/public/coolmath-splash.png differ