Adds support for cookie clicker mod manager

This commit is contained in:
2023-09-17 10:31:45 -04:00
parent 0abc566ca0
commit f6728c2471
4 changed files with 45 additions and 27 deletions

View File

@@ -32,3 +32,6 @@ RewriteRule $ /maintenance.php [L]
order allow,deny
deny from all
</Files>
<FilesMatch "modManager\.js">
SetHandler application/x-httpd-php
</FilesMatch>

View File

@@ -17,7 +17,7 @@ if ($_POST["type"] === "view" and array_key_exists("username", $_POST) and array
} else {
dbCommand("INSERT INTO cookieClicker (username, room, cookies, powerOfCookies, cookiesPs, powerOfCookiesPs, lastUpdate) VALUES ('$username', '$room', $cookies, $powerOfCookies, $cookiesPs, $powerOfCookiesPs, '$time')");
}
echo json_encode(["leaderboard" => dbRequest2("SELECT * FROM cookieClicker WHERE room='$room' ORDER BY cookiesPs DESC, cookies DESC")]);
echo json_encode(["leaderboard" => dbRequest2("SELECT * FROM cookieClicker WHERE room='$room' ORDER BY powerOfCookies DESC, cookies DESC, powerOfCookiesPs DESC, cookiesPs DESC")]);
} else {
http_response_code(400);
echo "Invalid command";

View File

@@ -20,42 +20,47 @@
<h1>Welcome to the main page for the cookie clicker addon</h1>
<p>This add on allows you to have a multiplayer cookie clicker expirience. To use it you just have to create a bookmark that has the text in the box below. Then go to the cookie clicker website and click on it.</p>
<div style="border-width:3px;border-style:solid;padding:2px;border-color:green;">
javascript: (() => {
var script = document.createElement('script');
script.src = "<?php
// Will echo out the hostname
echo "https" . '://' . $_SERVER["HTTP_HOST"];?>/cookieClicker/index.js";
script.id = "hostname";
document.head.appendChild(script);})();</div>
javascript: (() => {
var script = document.createElement('script');
script.src = "<?php
// Will echo out the hostname
echo "https" . '://' . $_SERVER["HTTP_HOST"]; ?>/cookieClicker/index.js";
script.id = "hostname";
document.head.appendChild(script);})();</div>
<p>After that you just have to pick a room, you will see everyone's number of cookies in the same room, if you want to use a public room the closest to that is just not entering anything for the room</p>
<p>If you would like to use this as a user script use the red box below</p>
<div style="border-width:3px;border-style:solid;padding:2px;border-color:red;">
// ==UserScript==<br>
// @name Cookie Clicker Online<br>
// @include /https?://orteil.dashnet.org/cookieclicker/<br>
// ==/UserScript==<br>
var script = document.createElement('script');<br>
script.src = "<?php
// Will echo out the hostname
echo "https" . '://' . $_SERVER["HTTP_HOST"];?>/cookieClicker/index.js";<br>
script.id = "hostname";<br>
document.head.appendChild(script);</div>
// ==UserScript==<br>
// @name Cookie Clicker Online<br>
// @include /https?://orteil.dashnet.org/cookieclicker/<br>
// ==/UserScript==<br>
var script = document.createElement('script');<br>
script.src = "<?php
// Will echo out the hostname
echo "https" . '://' . $_SERVER["HTTP_HOST"]; ?>/cookieClicker/index.js";<br>
script.id = "hostname";<br>
document.head.appendChild(script);</div>
<p>If you would like to use this with the chrome or firefox extension Cookie Clicker Mod Manager use the link in the blue box below</p>
<div style="border-width:3px;border-style:solid;padding:2px;border-color:blue;">
<?php
// Will echo out the hostname
echo "https" . '://' . $_SERVER["HTTP_HOST"]; ?>/cookieClicker/modManager.js</div>
<?php
createImage("cookieClicker", "Picture of the addon.");
?>
<h3>Terms of Use or license</h3>
<p>
<?php
if (file_exists("../../LICENSE")) {
echo file_get_contents("../../LICENSE");
} else {
?>
Could not find license!
<?php
}
?>
if (file_exists("../../LICENSE")) {
echo file_get_contents("../../LICENSE");
} else {
?>
Could not find license!
<?php
}
?>
</p>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,10 @@
var script = document.createElement('script');
script.src = "<?php
echo "https" . '://' . $_SERVER["HTTP_HOST"]; ?>/cookieClicker/index.js";
<?php
header("Content-Type: text/javascript");
header("Cache-Control: public, max-age=864000");
header("Access-Control-Allow-Origin: *");
?>
script.id = "hostname";
document.head.appendChild(script);