diff --git a/dist/extension.zip b/dist/extension.zip index 72e789a..70fc735 100644 Binary files a/dist/extension.zip and b/dist/extension.zip differ diff --git a/dist/extension/birb.js b/dist/extension/birb.js index c3b7a66..446faa3 100644 --- a/dist/extension/birb.js +++ b/dist/extension/birb.js @@ -2048,7 +2048,6 @@ // Timing constants (in milliseconds) const UPDATE_INTERVAL = 1000 / 60; // 60 FPS const AFK_TIME = isDebug() ? 0 : 1000 * 5; - const PET_BOOST_DURATION = 1000 * 60 * 5; const PET_MENU_COOLDOWN = 1000; const URL_CHECK_INTERVAL = 150; const HOP_DELAY = 500; @@ -2057,10 +2056,15 @@ const HOP_CHANCE = 1 / (60 * 2.5); // Every 2.5 seconds const FOCUS_SWITCH_CHANCE = 1 / (60 * 20); // Every 20 seconds const FEATHER_CHANCE = 1 / (60 * 60 * 60 * 2); // Every 2 hours + const HAT_CHANCE = 1 / 50; // Every 50 webpages // Feathers const FEATHER_FALL_SPEED = 1; + + // Petting boosts + const PET_BOOST_DURATION = 1000 * 60 * 5; // 5 minutes const PET_FEATHER_BOOST = 2; + const PET_HAT_BOOST = 1.5; // Focus element constraints const MIN_FOCUS_ELEMENT_WIDTH = 100; @@ -2311,7 +2315,8 @@ // Currently being pet, don't open menu return; } - insertMenu(menuItems, `${birdBirb().toLowerCase()}OS`, updateMenuLocation); + + insertMenu(menuItems, `${isPetBoostActive() ? " " : ""}${birdBirb().toLowerCase()}OS${isPetBoostActive() ? " ❤" : ""}`, updateMenuLocation); }); birbElement.addEventListener("mouseover", () => { @@ -2340,9 +2345,10 @@ setInterval(() => { const currentPath = getContext().getPath().split("?")[0]; if (currentPath !== lastPath) { - log("Path changed, updating sticky notes: " + currentPath); + log("Path changed from '" + lastPath + "' to '" + currentPath + "'"); lastPath = currentPath; drawStickyNotes(stickyNotes, save, deleteStickyNote); + determineHatUnlock(); } }, URL_CHECK_INTERVAL); @@ -2350,8 +2356,16 @@ focusOnElement(true); - // TODO: This is for testing - insertHat(); + determineHatUnlock(); + } + + function determineHatUnlock() { + if (Math.random() < (HAT_CHANCE * (isPetBoostActive() ? PET_HAT_BOOST : 1))) { + insertHat(); + } else if (location.hostname === "127.0.0.1") { + log("Inserting hat for debug purposes"); + insertHat(); + } } function update() { @@ -2385,7 +2399,7 @@ } // Double the chance of a feather if recently pet - const petMod = Date.now() - lastPetTimestamp < PET_BOOST_DURATION ? PET_FEATHER_BOOST : 1; + const petMod = isPetBoostActive() ? PET_FEATHER_BOOST : 1; if (birb.isVisible() && Math.random() < FEATHER_CHANCE * petMod) { lastPetTimestamp = 0; activateFeather(); @@ -3048,6 +3062,10 @@ } } + function isPetBoostActive() { + return Date.now() - lastPetTimestamp < PET_BOOST_DURATION; + } + /** * @param {number} x * @param {number} y diff --git a/dist/obsidian/main.js b/dist/obsidian/main.js index 716ca26..75e4461 100644 --- a/dist/obsidian/main.js +++ b/dist/obsidian/main.js @@ -2091,7 +2091,6 @@ module.exports = class PocketBird extends Plugin { // Timing constants (in milliseconds) const UPDATE_INTERVAL = 1000 / 60; // 60 FPS const AFK_TIME = isDebug() ? 0 : 1000 * 5; - const PET_BOOST_DURATION = 1000 * 60 * 5; const PET_MENU_COOLDOWN = 1000; const URL_CHECK_INTERVAL = 150; const HOP_DELAY = 500; @@ -2100,10 +2099,15 @@ module.exports = class PocketBird extends Plugin { const HOP_CHANCE = 1 / (60 * 2.5); // Every 2.5 seconds const FOCUS_SWITCH_CHANCE = 1 / (60 * 20); // Every 20 seconds const FEATHER_CHANCE = 1 / (60 * 60 * 60 * 2); // Every 2 hours + const HAT_CHANCE = 1 / 50; // Every 50 webpages // Feathers const FEATHER_FALL_SPEED = 1; + + // Petting boosts + const PET_BOOST_DURATION = 1000 * 60 * 5; // 5 minutes const PET_FEATHER_BOOST = 2; + const PET_HAT_BOOST = 1.5; // Focus element constraints const MIN_FOCUS_ELEMENT_WIDTH = 100; @@ -2354,7 +2358,8 @@ module.exports = class PocketBird extends Plugin { // Currently being pet, don't open menu return; } - insertMenu(menuItems, `${birdBirb().toLowerCase()}OS`, updateMenuLocation); + + insertMenu(menuItems, `${isPetBoostActive() ? " " : ""}${birdBirb().toLowerCase()}OS${isPetBoostActive() ? " ❤" : ""}`, updateMenuLocation); }); birbElement.addEventListener("mouseover", () => { @@ -2383,9 +2388,10 @@ module.exports = class PocketBird extends Plugin { setInterval(() => { const currentPath = getContext().getPath().split("?")[0]; if (currentPath !== lastPath) { - log("Path changed, updating sticky notes: " + currentPath); + log("Path changed from '" + lastPath + "' to '" + currentPath + "'"); lastPath = currentPath; drawStickyNotes(stickyNotes, save, deleteStickyNote); + determineHatUnlock(); } }, URL_CHECK_INTERVAL); @@ -2393,8 +2399,16 @@ module.exports = class PocketBird extends Plugin { focusOnElement(true); - // TODO: This is for testing - insertHat(); + determineHatUnlock(); + } + + function determineHatUnlock() { + if (Math.random() < (HAT_CHANCE * (isPetBoostActive() ? PET_HAT_BOOST : 1))) { + insertHat(); + } else if (location.hostname === "127.0.0.1") { + log("Inserting hat for debug purposes"); + insertHat(); + } } function update() { @@ -2428,7 +2442,7 @@ module.exports = class PocketBird extends Plugin { } // Double the chance of a feather if recently pet - const petMod = Date.now() - lastPetTimestamp < PET_BOOST_DURATION ? PET_FEATHER_BOOST : 1; + const petMod = isPetBoostActive() ? PET_FEATHER_BOOST : 1; if (birb.isVisible() && Math.random() < FEATHER_CHANCE * petMod) { lastPetTimestamp = 0; activateFeather(); @@ -3091,6 +3105,10 @@ module.exports = class PocketBird extends Plugin { } } + function isPetBoostActive() { + return Date.now() - lastPetTimestamp < PET_BOOST_DURATION; + } + /** * @param {number} x * @param {number} y diff --git a/dist/userscript/birb.user.js b/dist/userscript/birb.user.js index 83a501f..c20e185 100644 --- a/dist/userscript/birb.user.js +++ b/dist/userscript/birb.user.js @@ -2053,7 +2053,6 @@ // Timing constants (in milliseconds) const UPDATE_INTERVAL = 1000 / 60; // 60 FPS const AFK_TIME = isDebug() ? 0 : 1000 * 5; - const PET_BOOST_DURATION = 1000 * 60 * 5; const PET_MENU_COOLDOWN = 1000; const URL_CHECK_INTERVAL = 150; const HOP_DELAY = 500; @@ -2062,10 +2061,15 @@ const HOP_CHANCE = 1 / (60 * 2.5); // Every 2.5 seconds const FOCUS_SWITCH_CHANCE = 1 / (60 * 20); // Every 20 seconds const FEATHER_CHANCE = 1 / (60 * 60 * 60 * 2); // Every 2 hours + const HAT_CHANCE = 1 / 50; // Every 50 webpages // Feathers const FEATHER_FALL_SPEED = 1; + + // Petting boosts + const PET_BOOST_DURATION = 1000 * 60 * 5; // 5 minutes const PET_FEATHER_BOOST = 2; + const PET_HAT_BOOST = 1.5; // Focus element constraints const MIN_FOCUS_ELEMENT_WIDTH = 100; @@ -2316,7 +2320,8 @@ // Currently being pet, don't open menu return; } - insertMenu(menuItems, `${birdBirb().toLowerCase()}OS`, updateMenuLocation); + + insertMenu(menuItems, `${isPetBoostActive() ? " " : ""}${birdBirb().toLowerCase()}OS${isPetBoostActive() ? " ❤" : ""}`, updateMenuLocation); }); birbElement.addEventListener("mouseover", () => { @@ -2345,9 +2350,10 @@ setInterval(() => { const currentPath = getContext().getPath().split("?")[0]; if (currentPath !== lastPath) { - log("Path changed, updating sticky notes: " + currentPath); + log("Path changed from '" + lastPath + "' to '" + currentPath + "'"); lastPath = currentPath; drawStickyNotes(stickyNotes, save, deleteStickyNote); + determineHatUnlock(); } }, URL_CHECK_INTERVAL); @@ -2355,8 +2361,16 @@ focusOnElement(true); - // TODO: This is for testing - insertHat(); + determineHatUnlock(); + } + + function determineHatUnlock() { + if (Math.random() < (HAT_CHANCE * (isPetBoostActive() ? PET_HAT_BOOST : 1))) { + insertHat(); + } else if (location.hostname === "127.0.0.1") { + log("Inserting hat for debug purposes"); + insertHat(); + } } function update() { @@ -2390,7 +2404,7 @@ } // Double the chance of a feather if recently pet - const petMod = Date.now() - lastPetTimestamp < PET_BOOST_DURATION ? PET_FEATHER_BOOST : 1; + const petMod = isPetBoostActive() ? PET_FEATHER_BOOST : 1; if (birb.isVisible() && Math.random() < FEATHER_CHANCE * petMod) { lastPetTimestamp = 0; activateFeather(); @@ -3053,6 +3067,10 @@ } } + function isPetBoostActive() { + return Date.now() - lastPetTimestamp < PET_BOOST_DURATION; + } + /** * @param {number} x * @param {number} y diff --git a/dist/web/birb.embed.js b/dist/web/birb.embed.js index 9520421..46f338b 100644 --- a/dist/web/birb.embed.js +++ b/dist/web/birb.embed.js @@ -2033,7 +2033,6 @@ // Timing constants (in milliseconds) const UPDATE_INTERVAL = 1000 / 60; // 60 FPS const AFK_TIME = isDebug() ? 0 : 1000 * 5; - const PET_BOOST_DURATION = 1000 * 60 * 5; const PET_MENU_COOLDOWN = 1000; const URL_CHECK_INTERVAL = 150; const HOP_DELAY = 500; @@ -2042,10 +2041,15 @@ const HOP_CHANCE = 1 / (60 * 2.5); // Every 2.5 seconds const FOCUS_SWITCH_CHANCE = 1 / (60 * 20); // Every 20 seconds const FEATHER_CHANCE = 1 / (60 * 60 * 60 * 2); // Every 2 hours + const HAT_CHANCE = 1 / 50; // Every 50 webpages // Feathers const FEATHER_FALL_SPEED = 1; + + // Petting boosts + const PET_BOOST_DURATION = 1000 * 60 * 5; // 5 minutes const PET_FEATHER_BOOST = 2; + const PET_HAT_BOOST = 1.5; // Focus element constraints const MIN_FOCUS_ELEMENT_WIDTH = 100; @@ -2296,7 +2300,8 @@ // Currently being pet, don't open menu return; } - insertMenu(menuItems, `${birdBirb().toLowerCase()}OS`, updateMenuLocation); + + insertMenu(menuItems, `${isPetBoostActive() ? " " : ""}${birdBirb().toLowerCase()}OS${isPetBoostActive() ? " ❤" : ""}`, updateMenuLocation); }); birbElement.addEventListener("mouseover", () => { @@ -2325,9 +2330,10 @@ setInterval(() => { const currentPath = getContext().getPath().split("?")[0]; if (currentPath !== lastPath) { - log("Path changed, updating sticky notes: " + currentPath); + log("Path changed from '" + lastPath + "' to '" + currentPath + "'"); lastPath = currentPath; drawStickyNotes(stickyNotes, save, deleteStickyNote); + determineHatUnlock(); } }, URL_CHECK_INTERVAL); @@ -2335,8 +2341,16 @@ focusOnElement(true); - // TODO: This is for testing - insertHat(); + determineHatUnlock(); + } + + function determineHatUnlock() { + if (Math.random() < (HAT_CHANCE * (isPetBoostActive() ? PET_HAT_BOOST : 1))) { + insertHat(); + } else if (location.hostname === "127.0.0.1") { + log("Inserting hat for debug purposes"); + insertHat(); + } } function update() { @@ -2370,7 +2384,7 @@ } // Double the chance of a feather if recently pet - const petMod = Date.now() - lastPetTimestamp < PET_BOOST_DURATION ? PET_FEATHER_BOOST : 1; + const petMod = isPetBoostActive() ? PET_FEATHER_BOOST : 1; if (birb.isVisible() && Math.random() < FEATHER_CHANCE * petMod) { lastPetTimestamp = 0; activateFeather(); @@ -3033,6 +3047,10 @@ } } + function isPetBoostActive() { + return Date.now() - lastPetTimestamp < PET_BOOST_DURATION; + } + /** * @param {number} x * @param {number} y diff --git a/dist/web/birb.js b/dist/web/birb.js index 9520421..46f338b 100644 --- a/dist/web/birb.js +++ b/dist/web/birb.js @@ -2033,7 +2033,6 @@ // Timing constants (in milliseconds) const UPDATE_INTERVAL = 1000 / 60; // 60 FPS const AFK_TIME = isDebug() ? 0 : 1000 * 5; - const PET_BOOST_DURATION = 1000 * 60 * 5; const PET_MENU_COOLDOWN = 1000; const URL_CHECK_INTERVAL = 150; const HOP_DELAY = 500; @@ -2042,10 +2041,15 @@ const HOP_CHANCE = 1 / (60 * 2.5); // Every 2.5 seconds const FOCUS_SWITCH_CHANCE = 1 / (60 * 20); // Every 20 seconds const FEATHER_CHANCE = 1 / (60 * 60 * 60 * 2); // Every 2 hours + const HAT_CHANCE = 1 / 50; // Every 50 webpages // Feathers const FEATHER_FALL_SPEED = 1; + + // Petting boosts + const PET_BOOST_DURATION = 1000 * 60 * 5; // 5 minutes const PET_FEATHER_BOOST = 2; + const PET_HAT_BOOST = 1.5; // Focus element constraints const MIN_FOCUS_ELEMENT_WIDTH = 100; @@ -2296,7 +2300,8 @@ // Currently being pet, don't open menu return; } - insertMenu(menuItems, `${birdBirb().toLowerCase()}OS`, updateMenuLocation); + + insertMenu(menuItems, `${isPetBoostActive() ? " " : ""}${birdBirb().toLowerCase()}OS${isPetBoostActive() ? " ❤" : ""}`, updateMenuLocation); }); birbElement.addEventListener("mouseover", () => { @@ -2325,9 +2330,10 @@ setInterval(() => { const currentPath = getContext().getPath().split("?")[0]; if (currentPath !== lastPath) { - log("Path changed, updating sticky notes: " + currentPath); + log("Path changed from '" + lastPath + "' to '" + currentPath + "'"); lastPath = currentPath; drawStickyNotes(stickyNotes, save, deleteStickyNote); + determineHatUnlock(); } }, URL_CHECK_INTERVAL); @@ -2335,8 +2341,16 @@ focusOnElement(true); - // TODO: This is for testing - insertHat(); + determineHatUnlock(); + } + + function determineHatUnlock() { + if (Math.random() < (HAT_CHANCE * (isPetBoostActive() ? PET_HAT_BOOST : 1))) { + insertHat(); + } else if (location.hostname === "127.0.0.1") { + log("Inserting hat for debug purposes"); + insertHat(); + } } function update() { @@ -2370,7 +2384,7 @@ } // Double the chance of a feather if recently pet - const petMod = Date.now() - lastPetTimestamp < PET_BOOST_DURATION ? PET_FEATHER_BOOST : 1; + const petMod = isPetBoostActive() ? PET_FEATHER_BOOST : 1; if (birb.isVisible() && Math.random() < FEATHER_CHANCE * petMod) { lastPetTimestamp = 0; activateFeather(); @@ -3033,6 +3047,10 @@ } } + function isPetBoostActive() { + return Date.now() - lastPetTimestamp < PET_BOOST_DURATION; + } + /** * @param {number} x * @param {number} y diff --git a/src/application.js b/src/application.js index d136947..85ee48c 100644 --- a/src/application.js +++ b/src/application.js @@ -100,7 +100,6 @@ const HOP_DISTANCE = 35; // Timing constants (in milliseconds) const UPDATE_INTERVAL = 1000 / 60; // 60 FPS const AFK_TIME = isDebug() ? 0 : 1000 * 5; -const PET_BOOST_DURATION = 1000 * 60 * 5; const PET_MENU_COOLDOWN = 1000; const URL_CHECK_INTERVAL = 150; const HOP_DELAY = 500; @@ -109,10 +108,15 @@ const HOP_DELAY = 500; const HOP_CHANCE = 1 / (60 * 2.5); // Every 2.5 seconds const FOCUS_SWITCH_CHANCE = 1 / (60 * 20); // Every 20 seconds const FEATHER_CHANCE = 1 / (60 * 60 * 60 * 2); // Every 2 hours +const HAT_CHANCE = 1 / 50; // Every 50 webpages // Feathers const FEATHER_FALL_SPEED = 1; + +// Petting boosts +const PET_BOOST_DURATION = 1000 * 60 * 5; // 5 minutes const PET_FEATHER_BOOST = 2; +const PET_HAT_BOOST = 1.5; // Focus element constraints const MIN_FOCUS_ELEMENT_WIDTH = 100; @@ -363,7 +367,8 @@ function startApplication(birbPixels, featherPixels, hatsPixels) { // Currently being pet, don't open menu return; } - insertMenu(menuItems, `${birdBirb().toLowerCase()}OS`, updateMenuLocation); + + insertMenu(menuItems, `${isPetBoostActive() ? " " : ""}${birdBirb().toLowerCase()}OS${isPetBoostActive() ? " ❤" : ""}`, updateMenuLocation); }); birbElement.addEventListener("mouseover", () => { @@ -392,9 +397,10 @@ function startApplication(birbPixels, featherPixels, hatsPixels) { setInterval(() => { const currentPath = getContext().getPath().split("?")[0]; if (currentPath !== lastPath) { - log("Path changed, updating sticky notes: " + currentPath); + log("Path changed from '" + lastPath + "' to '" + currentPath + "'"); lastPath = currentPath; drawStickyNotes(stickyNotes, save, deleteStickyNote); + determineHatUnlock(); } }, URL_CHECK_INTERVAL); @@ -402,8 +408,16 @@ function startApplication(birbPixels, featherPixels, hatsPixels) { focusOnElement(true); - // TODO: This is for testing - insertHat(); + determineHatUnlock(); + } + + function determineHatUnlock() { + if (Math.random() < (HAT_CHANCE * (isPetBoostActive() ? PET_HAT_BOOST : 1))) { + insertHat(); + } else if (location.hostname === "127.0.0.1") { + log("Inserting hat for debug purposes"); + insertHat(); + } } function update() { @@ -437,7 +451,7 @@ function startApplication(birbPixels, featherPixels, hatsPixels) { } // Double the chance of a feather if recently pet - const petMod = Date.now() - lastPetTimestamp < PET_BOOST_DURATION ? PET_FEATHER_BOOST : 1; + const petMod = isPetBoostActive() ? PET_FEATHER_BOOST : 1; if (birb.isVisible() && Math.random() < FEATHER_CHANCE * petMod) { lastPetTimestamp = 0; activateFeather(); @@ -1114,6 +1128,10 @@ function startApplication(birbPixels, featherPixels, hatsPixels) { } } + function isPetBoostActive() { + return Date.now() - lastPetTimestamp < PET_BOOST_DURATION; + } + /** * @param {number} x * @param {number} y