// ==UserScript== // @name Good Old Kongregate // @namespace https://greasyfork.org/users/1206953 // @version 1.4.6 // @description Gone but not forgotten - browse Kongregate with the pre-2023 style // @author Fancy2209, Matrix4348 // @match *://www.kongregate.com/* // @icon https://matrix4348.github.io/logos/kongregate.png // @grant GM_info // @grant GM_getValue // @grant GM_setValue // @grant GM_registerMenuCommand // @grant GM_unregisterMenuCommand // @grant unsafeWindow // @run-at document-start // @downloadURL https://update.greasyfork.icu/scripts/503997/Good%20Old%20Kongregate.user.js // @updateURL https://update.greasyfork.icu/scripts/503997/Good%20Old%20Kongregate.meta.js // ==/UserScript== // Various GM_* functions disappeared in Greasemonkey 4 (which is the Greasemonkey for modern Firefox), so we will define them as useless functions so the script does not break. // I chose not to make them work in Greasemonkey 4 because the workaround (which is NOT hard to implement) would force us to use async functions in some places. This would, in my opinion, needlessly complexify // the code. if( typeof(GM_getValue)=="undefined" ){ GM_getValue=function(a,b){ return b; }; } if( typeof(GM_setValue)=="undefined" ){ GM_setValue=function(){}; } if( typeof(GM_registerMenuCommand)=="undefined" ){ GM_registerMenuCommand=function(){}; } if( typeof(GM_unregisterMenuCommand)=="undefined" ){ GM_unregisterMenuCommand=function(){}; } function registerMenuCommand(t,f,o){ var n=GM_info.scriptHandler.toLowerCase(); var v0=GM_info.version[0]; if(n=="greasemonkey"){ if(v0==4){ // Do nothing... for now? } else{ // A third argument breaks GM_registerMenuCommand ("accessKey must be a single character") on Pale Moon. // I am assuming that the problem is shared across all browsers, for Greasemonkey 3... and below. GM_registerMenuCommand(t,f); } } else{ GM_registerMenuCommand(t,f,o); } } //// var unsupported_pages = [ // Use (|/fr|/de) after .com in order to take localized pages into account. // Notes: . is a wildcard for one character, * represents several occurences of what if follows, (?!X) means "only if not followed by X", (.*?) means anything. // Note: (\[A-Za-z0-9_\]) means anything that is a latin letter, arabic digit or underscore. "www.kongregate.com(|/fr|/de)/achievements", "www.kongregate.com(|/fr|/de)/search", "www.kongregate.com(|/fr|/de)/games(?!.)", // Target: https://www.kongregate.com/games but not https://www.kongregate.com/games_for_your_site or game pages "www.kongregate.com((?!/games/)|/fr(?!/games/)|/de(?!/games/))/(.*?)-games", // Targets: pages like https://www.kongregate.com/puzzle-games. Use of (?!/games/) because game names could end by "-games" or " games". "www.kongregate.com(|/fr|/de)/games/(\[A-Za-z0-9_\]*)/?(?!.)", // Targets: www.kongregate.com/games/dev and www.kongregate.com/games/dev/ but not www.kongregate.com/games/dev/game ]; function is_unsupported(){ var url=document.location.href; for(let p of unsupported_pages){ if(url.search(p)>-1){ return true; } } return false; } function PutWarningOnUnsupportedPages(A){ if(typeof(document.body?.firstElementChild)!="undefined" && is_unsupported()){ var d=document.createElement("div"); d.style.textAlign="center"; d.style.margin="5px"; d.style.fontSize="12px"; d.style.fontStyle="italic"; var nv=(GM_info.scriptHandler+GM_info.version).toLowerCase().substring(0,13); var good, bad; good="Good Old Kongregate is partly disabled by default on this page because some of its features might completely break it. However, you can toggle the full user script on and off on unsupported pages from the "+GM_info.scriptHandler+" menu (click the extension icon or right click the page)."; bad="Good Old Kongregate is partly disabled by default on this page because some of its features might completely break it."; // Reminder: on Greasemonkey 4, most GM_ functions do not work. d.innerHTML= nv=="greasemonkey4" ? bad : good; document.body.insertBefore(d,document.body.firstElementChild); } else if(A){ setTimeout(function(B){ PutWarningOnUnsupportedPages(B); },1000, A-1); } } function toggle_command(){ var x = { true: "Disable Good Old Kongregate on unsupported pages", false:"Enable Good Old Kongregate on unsupported pages" }; var e = GM_getValue("enable_on_unsupported",false); if( GM_info.scriptHandler.toLowerCase()!="greasemonkey" || GM_info.version[0]>3 ){ GM_unregisterMenuCommand(x[e]); registerMenuCommand(x[!e],toggle_command,{id:x[!e],autoClose:false}); } GM_setValue("enable_on_unsupported",!e); } var x = { true: "Disable Good Old Kongregate on unsupported pages", false:"Enable Good Old Kongregate on unsupported pages" }; if( GM_info.scriptHandler.toLowerCase()!="greasemonkey" || GM_info.version[0]>3 ){ registerMenuCommand(x[GM_getValue("enable_on_unsupported",false)],toggle_command,{id:x[GM_getValue("enable_on_unsupported",false)],autoClose:false}); } else{ registerMenuCommand("Enable or disable Good Old Kongregate on unsupported pages",toggle_command,{id:x[GM_getValue("enable_on_unsupported",false)],autoClose:false}); } function TimeToLogin(active_user){ function updatePlaylist() { if(!active_user.playLatersCount){ active_user.playLatersCount=function(){ return 0; } } var e = active_user.playLatersCount(); Array.from(document.getElementsByClassName("play-laters-count-link")).forEach(function (t) { t.title = e + " games in your playlist."; t.querySelector(".play-laters-count").innerHTML=e; }); } function updateFavorites() { var e = active_user.favoritesCount(); Array.from(document.getElementsByClassName("favorites-count-link")).forEach(function (t) { t.title = e + " favorites."; t.querySelector(".favorites-count").innerHTML=e; }); } function updateFriendInfo(e) { Array.from(e.getElementsByClassName("friends_online_count")).forEach(function (e) { e.innerHTML=active_user.friendsOnlineCount(); }); active_user.friendsOnlineCount() > 0 ? Array.from(e.getElementsByClassName("friends_online_link")).forEach(function (e) { e.title = active_user.friendsOnlineNames(); }) : Array.from(e.getElementsByClassName("friends_online_link")).forEach(function (e) { e.title = "No friends online."; }); } var go=0, t = document.getElementById("welcome"); if(typeof(active_user)!="undefined"){ if (active_user.isAuthenticated() && t!=null){ go=1;} } if(go){ var e = active_user.getAttributes(); updateFriendInfo(t); updatePlaylist(); updateFavorites(); var n = document.createElement("img"); n.id = "welcome_box_small_user_avatar"; n.src = e.avatar_url; n.title = e.username; n.name = "user_avatar"; n.alt = "Avatar for " + e.username; n.height = 28; n.width = 28; t.querySelector("span#small_avatar_placeholder").innerHTML=""; t.querySelector("span#small_avatar_placeholder").appendChild(n); Array.from(t.getElementsByClassName("facebook_nav_item")).forEach(function (e) { active_user.isFacebookConnected() && e.hide(); }); document.getElementById("mini-profile-level").setAttribute("class", "spritesite levelbug level_" + e.level); document.getElementById("mini-profile-level").setAttribute("title", "Level " + e.level); active_user.populateUserSpecificLinks(t); Array.from(t.getElementsByClassName("username_holder")).forEach(function (e) { e.innerHTML=active_user.username(); }); var a = active_user.unreadShoutsCount() + active_user.unreadWhispersCount() + active_user.unreadGameMessagesCount(); if(a > 0){ document.getElementById("profile_bar_messages").classList.add("alert_messages"); document.getElementById("profile_control_unread_message_count").innerHTML=a; document.getElementById("profile_control_unread_message_count").classList.add("mls","has_messages"); document.getElementById("my-messages-link").setAttribute("title", active_user.unreadShoutsCount() + " shouts, " + active_user.unreadWhispersCount() + " whispers"); 0 !== active_user.unreadWhispersCount() ? document.getElementById("my-messages-link").setAttribute("href", "/accounts/" + active_user.username() + "/private_messages") : 0 !== active_user.unreadGameMessagesCount() && document.getElementById("my-messages-link").setAttribute("href", "/accounts/" + active_user.username() + "/game_messages"); } if(null !== active_user.chipsBalance()){ document.getElementById("blocks_balance").innerHTML=active_user.chipsBalance(); } document.getElementById("blocks").style.display=""; document.getElementById("guest_user_welcome_content").style.display="none"; document.getElementById("nav_welcome_box").style.display=""; } else{ setTimeout(function(){ TimeToLogin(unsafeWindow.active_user); },1); } } function ReopenChat(A,holodeck){ var go=0; if(typeof(holodeck)!="undefined" && document.getElementById("chat_tab")!=null){ if(holodeck.ready){ go=1; } } if(go){ document.getElementById("chat_tab").style.display="";} else if(A){ setTimeout(function(B){ ReopenChat(B,unsafeWindow.holodeck); },1000, A-1); } } function fill_games_tab(A,navigationData){ if(typeof(navigationData)!="undefined"){ if(navigationData.user.authenticated){ document.getElementById("GOK_recently_played").setAttribute("href",navigationData.user.recently_played_path); var l=navigationData.games.recently_played.length; if(l>0){ document.getElementById("GOK_no_recently_played_game").style.display="none"; document.getElementById("GOK_recently_played_1").style.display=""; document.getElementById("GOK1_image").setAttribute("src",navigationData.games.recently_played[0].icon_path); document.getElementById("GOK1_name").innerText=navigationData.games.recently_played[0].title; document.getElementById("GOK_recently_played_1").setAttribute("href",navigationData.games.recently_played[0].game_path); for(let k=1; k0){ document.getElementById("GOK_no_playlist").style.display="none"; document.getElementById("GOK_playlist_1").style.display=""; document.getElementById("GOK_playlist_1_image").setAttribute("src",navigationData.games.playlist[0].icon_path); document.getElementById("GOK_playlist_1_name").innerText=navigationData.games.playlist[0].title; document.getElementById("GOK_playlist_1").setAttribute("href",navigationData.games.playlist[0].game_path); for(let k=1; k-1 && n.getAttribute("data-turbo-track")=="reload"){ if(remove_new){ n.remove(); } let goodKongCSS = document.createElement('link'); goodKongCSS.rel = 'stylesheet'; goodKongCSS.setAttribute('data-turbo-track', 'reload'); goodKongCSS.href = 'https://fancy2209.github.io/KOG/GamePage.css'; document.head.appendChild(goodKongCSS); } else if(n.href.search("application_merged")>-1 && n.getAttribute("data-turbo-track")=="reload"){ if(remove_new){ n.remove(); } let goodKongCSS = document.createElement('link'); goodKongCSS.rel = 'stylesheet'; goodKongCSS.setAttribute('data-turbo-track', 'reload'); goodKongCSS.href = 'https://fancy2209.github.io/KOG/Main.css'; document.head.appendChild(goodKongCSS); } else if(n.href.search("application-")>-1 && n.getAttribute("data-turbo-track")=="reload"){ if(remove_new){ n.remove(); } } } // Because Kongregate obviously adds new content (like the medal of the "iron, fire and explosions" quest) with the new styles in mind, some parts of those must be kept. var s=document.createElement("style"); s.innerHTML=` img,video { max-width: 100%; height: auto; } `; document.head.appendChild(s); } function replace_favicon(){ var I=document.head.querySelectorAll('link[rel="icon"]'); for(let i of I){ if(i.type=="image/svg+xml"){ i.href = "https://github.com/Fancy2209/Good-Old-Kongregate/raw/main/Icon/icon.svg"; } else{ i.href = "https://raw.githubusercontent.com/Fancy2209/Good-Old-Kongregate/main/Icon/kong.png"; } } } function switch_banner(C){ var e=document.getElementsByClassName("home_feat_items")[0].getElementsByClassName("focus")[0]; if(C=="next"){ e.classList.remove("focus"); (e.nextElementSibling||e.parentElement.firstElementChild).classList.add("focus"); } else if(C=="previous"){ e.classList.remove("focus"); (e.previousElementSibling||e.parentElement.lastElementChild).classList.add("focus"); } } function replace_homepage_banners(node,homepage_primarywrap){ let pw=document.createElement("div"); pw.id="primarywrap"; pw.classList.add("divider"); let banners=node.getElementsByClassName("home_feat_items")[0].innerHTML; pw.innerHTML=homepage_primarywrap; node.parentElement.insertBefore(pw, node); node.remove(); document.getElementsByClassName("home_feat_items")[0].innerHTML=banners; document.getElementsByClassName("home_feat_nav")[0].getElementsByClassName("prev")[0].addEventListener("click",function(){switch_banner("previous");}); document.getElementsByClassName("home_feat_nav")[0].getElementsByClassName("next mls")[0].addEventListener("click",function(){switch_banner("next");}); } function ThingsToDoAtTheEnd(holodeck){ PutWarningOnUnsupportedPages(50); ReopenChat(50,holodeck); }; (function() { 'use strict'; // Find the Things const headerWrap = ` `; const footer = `

Kong Plus

Kong Plus

Get more out of your Kongregate experience. Take advantage of ad-free gaming, cool profile skins, automatic beta access, and private chat with Kong Plus. Learn more »

Are you a game developer? Visit our Developers Site where you can find documentation on our APIs and more information about publishing opportunities to further promote your game. Learn More `; const homepage_primarywrap =`

Kongregate: Play free games online

    Our Published Games (see all)

    Royal Idle - Medieval Quest

    Collect gold and emeralds, build your kingdom, and journey to new adventure!

    Download on the App Store & Get it on Google Play

    Game Spotlights

    Sponsored Listings
    Promoted Listings
    `; var v1=0, v2=0, v3=0, v4=0, v5=0, v6=0, v7=0, v8=0, v9=0, v10=0; var targetNode = document; var config = { childList: true, subtree: true }; var callback = (mutationList, observer) => { for (let mutation of mutationList) { for(let node of mutation.addedNodes){ if (mutation.type === 'childList') { if(v1==0 && node.tagName=="K-NAVBAR"){ v1=1; let n=document.createElement("div"); n.id="headerwrap"; n.innerHTML = headerWrap; node.parentElement.insertBefore(n, node); node.remove(); TimeToLogin(unsafeWindow.active_user); fill_games_tab(50,unsafeWindow.navigationData); replace_css(!is_unsupported() || GM_getValue("enable_on_unsupported",false)); replace_favicon(); } else if(v1==1 && node.tagName=="K-NAVBAR"){ node.remove(); // Note: sitewide_javascripts will raise the following exception: Uncaught TypeError: t(...).parentNode is null // This does not seem to cause any issue besides polluting the console. } else if(v2==0 && node.id=="footer" && node.tagName=="K-FOOTER"){ v2=1; let n=document.createElement("div"); n.id="footer"; n.classList.add("clearfix"); n.innerHTML = footer; node.parentElement.insertBefore(n, node); node.remove(); } else if (v3==0 && node?.classList?.contains("sr-only")){ v3=1; node.style.display="none"; // This hides the new "Play [game] at Kongregate!" div, that is only visible with the old style. } else if (v4==0 && 0==1){ v4=1; // FREE } else if(v5==0 && node.id=="floating_game_holder"){ v5=1; document.getElementById("floating_game_holder").parentNode.style.backgroundColor="#2b2b2b"; document.getElementsByClassName("gamepage_header_outer")[0].classList.add("mbm"); // space between game name and the game document.getElementsByClassName("gamepage_header_outer")[0].classList.add("pbm"); // space between game name and the game node.parentNode.classList.add("upper_gamepage"); // To add space right below the game } else if(v6==0 && node.id=="global"){ // Changes from December 14th, 2023 moved game page banners below games v6=1; let pN=document.getElementById("progress_bar_target").parentNode; pN.insertBefore(node,document.getElementById("progress_bar_target")); let n=document.createElement("div"); n.classList.add("gamepage_categories_outer"); pN.insertBefore(n,node); // This node contained links to game categories, for the moment it will be added empty, for the margin. } else if(v7==0 && 0==1){ v7=1; // FREE } else if(v8==0 && document.URL=="https://www.kongregate.com/" && node.tagName=="MAIN"){ v8=1; document.addEventListener("DOMContentLoaded",function(){ replace_homepage_banners(node,homepage_primarywrap); }); } else if(v9==0 && node==document.body && document.getElementById("home")){ v9=1; node.classList.remove('lang_other', 'lang_en'); node.classList.add('new_home', 'no_subwrap', 'grid960'); } else if(v10==0 && (node.src||"").search("konstruct.min.js")>-1){ v10=1; if( !is_unsupported() || GM_getValue("enable_on_unsupported",false) ){ node.remove(); } } } } } }; var observer = new MutationObserver(callback); observer.observe(targetNode, config); ThingsToDoAtTheEnd(unsafeWindow.holodeck); })();