mirror of
https://github.com/NohamR/Pocket-Bird.git
synced 2026-05-25 04:07:23 +00:00
Fix all innerHTML calls
This commit is contained in:
116
dist/birb.js
vendored
116
dist/birb.js
vendored
@@ -1352,8 +1352,8 @@
|
|||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
padding-right: 10px;
|
padding-right: 10px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
justify-content: start;
|
justify-content: center;
|
||||||
align-items: start;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.birb-grid-item {
|
.birb-grid-item {
|
||||||
@@ -1398,6 +1398,7 @@
|
|||||||
|
|
||||||
.birb-field-guide-description {
|
.birb-field-guide-description {
|
||||||
width: calc(100% - 20px);
|
width: calc(100% - 20px);
|
||||||
|
margin-left: 10px;
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
padding-top: 4px;
|
padding-top: 4px;
|
||||||
@@ -1414,11 +1415,9 @@
|
|||||||
|
|
||||||
.birb-message-content {
|
.birb-message-content {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
margin: 2px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-top: 10px;
|
padding: 10px;
|
||||||
padding: 8px;
|
|
||||||
padding-top: 4px;
|
|
||||||
padding-bottom: 4px;
|
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: rgb(124, 108, 75);
|
color: rgb(124, 108, 75);
|
||||||
}
|
}
|
||||||
@@ -1596,10 +1595,17 @@
|
|||||||
new MenuItem("Toggle Birb Mode", () => {
|
new MenuItem("Toggle Birb Mode", () => {
|
||||||
userSettings.birbMode = !userSettings.birbMode;
|
userSettings.birbMode = !userSettings.birbMode;
|
||||||
save();
|
save();
|
||||||
insertModal(`${birdBirb()} Mode`, `Your ${birdBirb().toLowerCase()} shall now be referred to as "${birdBirb()}"${userSettings.birbMode ? "\n\nWelcome back to 2012" : ""}`);
|
const message = makeElement("birb-message-content");
|
||||||
|
message.appendChild(document.createTextNode(`Your ${birdBirb().toLowerCase()} shall now be referred to as "${birdBirb()}"`));
|
||||||
|
if (userSettings.birbMode) {
|
||||||
|
message.appendChild(document.createElement("br"));
|
||||||
|
message.appendChild(document.createElement("br"));
|
||||||
|
message.appendChild(document.createTextNode("Welcome back to 2012"));
|
||||||
|
}
|
||||||
|
insertModal(`${birdBirb()} Mode`, message);
|
||||||
}),
|
}),
|
||||||
new Separator(),
|
new Separator(),
|
||||||
new MenuItem("2025.10.26.500", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.10.26.500"); }, false),
|
new MenuItem("2025.10.26.536", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.10.26.536"); }, false),
|
||||||
];
|
];
|
||||||
|
|
||||||
const styleElement = document.createElement("style");
|
const styleElement = document.createElement("style");
|
||||||
@@ -1933,31 +1939,34 @@
|
|||||||
* Create a window element with header and content
|
* Create a window element with header and content
|
||||||
* @param {string} id
|
* @param {string} id
|
||||||
* @param {string} title
|
* @param {string} title
|
||||||
* @param {string} contentHtml
|
* @param {HTMLElement} contentElement
|
||||||
* @param {() => void} [onClose]
|
* @param {() => void} [onClose]
|
||||||
* @returns {HTMLElement}
|
* @returns {HTMLElement}
|
||||||
*/
|
*/
|
||||||
function createWindow(id, title, contentHtml, onClose) {
|
function createWindow(id, title, contentElement, onClose) {
|
||||||
const window = makeElement("birb-window", undefined, id);
|
const window = makeElement("birb-window", undefined, id);
|
||||||
window.innerHTML = `
|
|
||||||
<div class="birb-window-header">
|
const header = makeElement("birb-window-header");
|
||||||
<div class="birb-window-title">${title}</div>
|
const titleElement = makeElement("birb-window-title");
|
||||||
<div class="birb-window-close">x</div>
|
titleElement.textContent = title;
|
||||||
</div>
|
const closeButton = makeElement("birb-window-close");
|
||||||
<div class="birb-window-content">
|
closeButton.textContent = "x";
|
||||||
${contentHtml}
|
|
||||||
</div>
|
header.appendChild(titleElement);
|
||||||
`;
|
header.appendChild(closeButton);
|
||||||
|
|
||||||
|
const contentWrapper = makeElement("birb-window-content");
|
||||||
|
contentWrapper.appendChild(contentElement);
|
||||||
|
|
||||||
|
window.appendChild(header);
|
||||||
|
window.appendChild(contentWrapper);
|
||||||
|
|
||||||
document.body.appendChild(window);
|
document.body.appendChild(window);
|
||||||
makeDraggable(window.querySelector(".birb-window-header"));
|
makeDraggable(header);
|
||||||
|
|
||||||
const closeButton = window.querySelector(".birb-window-close");
|
|
||||||
if (closeButton) {
|
|
||||||
makeClosable(() => {
|
makeClosable(() => {
|
||||||
window.remove();
|
window.remove();
|
||||||
}, closeButton);
|
}, closeButton);
|
||||||
}
|
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
@@ -2017,7 +2026,13 @@
|
|||||||
function unlockBird(birdType) {
|
function unlockBird(birdType) {
|
||||||
if (!unlockedSpecies.includes(birdType)) {
|
if (!unlockedSpecies.includes(birdType)) {
|
||||||
unlockedSpecies.push(birdType);
|
unlockedSpecies.push(birdType);
|
||||||
insertModal("New Bird Unlocked!", `You've found a <b>${SPECIES[birdType].name}</b> feather! Use the Field Guide to switch your bird's species.`);
|
const message = makeElement("birb-message-content");
|
||||||
|
message.appendChild(document.createTextNode("You've found a "));
|
||||||
|
const bold = document.createElement("b");
|
||||||
|
bold.textContent = SPECIES[birdType].name;
|
||||||
|
message.appendChild(bold);
|
||||||
|
message.appendChild(document.createTextNode(" feather! Use the Field Guide to switch your bird's species."));
|
||||||
|
insertModal("New Bird Unlocked!", message);
|
||||||
}
|
}
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
@@ -2044,18 +2059,14 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} title
|
* @param {string} title
|
||||||
* @param {string} message
|
* @param {HTMLElement} content
|
||||||
*/
|
*/
|
||||||
function insertModal(title, message) {
|
function insertModal(title, content) {
|
||||||
if (document.querySelector("#" + FIELD_GUIDE_ID)) {
|
if (document.querySelector("#" + FIELD_GUIDE_ID)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const modal = createWindow("birb-modal", title, `
|
const modal = createWindow("birb-modal", title, content);
|
||||||
<div class="birb-message-content">
|
|
||||||
${message}
|
|
||||||
</div>
|
|
||||||
`);
|
|
||||||
|
|
||||||
modal.style.width = "270px";
|
modal.style.width = "270px";
|
||||||
centerElement(modal);
|
centerElement(modal);
|
||||||
@@ -2090,30 +2101,39 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const contentContainer = document.createElement("div");
|
||||||
|
const content = makeElement("birb-grid-content");
|
||||||
|
const description = makeElement("birb-field-guide-description");
|
||||||
|
contentContainer.appendChild(content);
|
||||||
|
contentContainer.appendChild(description);
|
||||||
|
|
||||||
const fieldGuide = createWindow(
|
const fieldGuide = createWindow(
|
||||||
FIELD_GUIDE_ID,
|
FIELD_GUIDE_ID,
|
||||||
"Field Guide",
|
"Field Guide",
|
||||||
`<div class="birb-grid-content"></div>
|
contentContainer
|
||||||
<div class="birb-field-guide-description"></div>`
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const content = fieldGuide.querySelector(".birb-grid-content");
|
|
||||||
if (!content) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
content.innerHTML = "";
|
|
||||||
|
|
||||||
const generateDescription = (/** @type {string} */ speciesId) => {
|
const generateDescription = (/** @type {string} */ speciesId) => {
|
||||||
const type = SPECIES[speciesId];
|
const type = SPECIES[speciesId];
|
||||||
const unlocked = unlockedSpecies.includes(speciesId);
|
const unlocked = unlockedSpecies.includes(speciesId);
|
||||||
return "<b>" + type.name + "</b><div style='height: 0.3em'></div>" + (!unlocked ? "Not yet unlocked" : type.description);
|
|
||||||
|
const boldName = document.createElement("b");
|
||||||
|
boldName.textContent = type.name;
|
||||||
|
|
||||||
|
const spacer = document.createElement("div");
|
||||||
|
spacer.style.height = "0.3em";
|
||||||
|
|
||||||
|
const descText = document.createTextNode(!unlocked ? "Not yet unlocked" : type.description);
|
||||||
|
|
||||||
|
const fragment = document.createDocumentFragment();
|
||||||
|
fragment.appendChild(boldName);
|
||||||
|
fragment.appendChild(spacer);
|
||||||
|
fragment.appendChild(descText);
|
||||||
|
|
||||||
|
return fragment;
|
||||||
};
|
};
|
||||||
|
|
||||||
const description = fieldGuide.querySelector(".birb-field-guide-description");
|
description.appendChild(generateDescription(currentSpecies));
|
||||||
if (!description) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
description.innerHTML = generateDescription(currentSpecies);
|
|
||||||
for (const [id, type] of Object.entries(SPECIES)) {
|
for (const [id, type] of Object.entries(SPECIES)) {
|
||||||
const unlocked = unlockedSpecies.includes(id);
|
const unlocked = unlockedSpecies.includes(id);
|
||||||
const speciesElement = makeElement("birb-grid-item");
|
const speciesElement = makeElement("birb-grid-item");
|
||||||
@@ -2142,10 +2162,12 @@
|
|||||||
speciesElement.classList.add("birb-grid-item-locked");
|
speciesElement.classList.add("birb-grid-item-locked");
|
||||||
}
|
}
|
||||||
speciesElement.addEventListener("mouseover", () => {
|
speciesElement.addEventListener("mouseover", () => {
|
||||||
description.innerHTML = generateDescription(id);
|
description.textContent = "";
|
||||||
|
description.appendChild(generateDescription(id));
|
||||||
});
|
});
|
||||||
speciesElement.addEventListener("mouseout", () => {
|
speciesElement.addEventListener("mouseout", () => {
|
||||||
description.innerHTML = generateDescription(currentSpecies);
|
description.textContent = "";
|
||||||
|
description.appendChild(generateDescription(currentSpecies));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
centerElement(fieldGuide);
|
centerElement(fieldGuide);
|
||||||
|
|||||||
118
dist/birb.user.js
vendored
118
dist/birb.user.js
vendored
@@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Pocket Bird
|
// @name Pocket Bird
|
||||||
// @namespace https://idreesinc.com
|
// @namespace https://idreesinc.com
|
||||||
// @version 2025.10.26.500
|
// @version 2025.10.26.536
|
||||||
// @description birb
|
// @description birb
|
||||||
// @author Idrees
|
// @author Idrees
|
||||||
// @downloadURL https://github.com/IdreesInc/Pocket-Bird/raw/refs/heads/main/dist/birb.user.js
|
// @downloadURL https://github.com/IdreesInc/Pocket-Bird/raw/refs/heads/main/dist/birb.user.js
|
||||||
@@ -1366,8 +1366,8 @@
|
|||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
padding-right: 10px;
|
padding-right: 10px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
justify-content: start;
|
justify-content: center;
|
||||||
align-items: start;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.birb-grid-item {
|
.birb-grid-item {
|
||||||
@@ -1412,6 +1412,7 @@
|
|||||||
|
|
||||||
.birb-field-guide-description {
|
.birb-field-guide-description {
|
||||||
width: calc(100% - 20px);
|
width: calc(100% - 20px);
|
||||||
|
margin-left: 10px;
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
padding-top: 4px;
|
padding-top: 4px;
|
||||||
@@ -1428,11 +1429,9 @@
|
|||||||
|
|
||||||
.birb-message-content {
|
.birb-message-content {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
margin: 2px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-top: 10px;
|
padding: 10px;
|
||||||
padding: 8px;
|
|
||||||
padding-top: 4px;
|
|
||||||
padding-bottom: 4px;
|
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: rgb(124, 108, 75);
|
color: rgb(124, 108, 75);
|
||||||
}
|
}
|
||||||
@@ -1610,10 +1609,17 @@
|
|||||||
new MenuItem("Toggle Birb Mode", () => {
|
new MenuItem("Toggle Birb Mode", () => {
|
||||||
userSettings.birbMode = !userSettings.birbMode;
|
userSettings.birbMode = !userSettings.birbMode;
|
||||||
save();
|
save();
|
||||||
insertModal(`${birdBirb()} Mode`, `Your ${birdBirb().toLowerCase()} shall now be referred to as "${birdBirb()}"${userSettings.birbMode ? "\n\nWelcome back to 2012" : ""}`);
|
const message = makeElement("birb-message-content");
|
||||||
|
message.appendChild(document.createTextNode(`Your ${birdBirb().toLowerCase()} shall now be referred to as "${birdBirb()}"`));
|
||||||
|
if (userSettings.birbMode) {
|
||||||
|
message.appendChild(document.createElement("br"));
|
||||||
|
message.appendChild(document.createElement("br"));
|
||||||
|
message.appendChild(document.createTextNode("Welcome back to 2012"));
|
||||||
|
}
|
||||||
|
insertModal(`${birdBirb()} Mode`, message);
|
||||||
}),
|
}),
|
||||||
new Separator(),
|
new Separator(),
|
||||||
new MenuItem("2025.10.26.500", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.10.26.500"); }, false),
|
new MenuItem("2025.10.26.536", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.10.26.536"); }, false),
|
||||||
];
|
];
|
||||||
|
|
||||||
const styleElement = document.createElement("style");
|
const styleElement = document.createElement("style");
|
||||||
@@ -1947,31 +1953,34 @@
|
|||||||
* Create a window element with header and content
|
* Create a window element with header and content
|
||||||
* @param {string} id
|
* @param {string} id
|
||||||
* @param {string} title
|
* @param {string} title
|
||||||
* @param {string} contentHtml
|
* @param {HTMLElement} contentElement
|
||||||
* @param {() => void} [onClose]
|
* @param {() => void} [onClose]
|
||||||
* @returns {HTMLElement}
|
* @returns {HTMLElement}
|
||||||
*/
|
*/
|
||||||
function createWindow(id, title, contentHtml, onClose) {
|
function createWindow(id, title, contentElement, onClose) {
|
||||||
const window = makeElement("birb-window", undefined, id);
|
const window = makeElement("birb-window", undefined, id);
|
||||||
window.innerHTML = `
|
|
||||||
<div class="birb-window-header">
|
const header = makeElement("birb-window-header");
|
||||||
<div class="birb-window-title">${title}</div>
|
const titleElement = makeElement("birb-window-title");
|
||||||
<div class="birb-window-close">x</div>
|
titleElement.textContent = title;
|
||||||
</div>
|
const closeButton = makeElement("birb-window-close");
|
||||||
<div class="birb-window-content">
|
closeButton.textContent = "x";
|
||||||
${contentHtml}
|
|
||||||
</div>
|
header.appendChild(titleElement);
|
||||||
`;
|
header.appendChild(closeButton);
|
||||||
|
|
||||||
|
const contentWrapper = makeElement("birb-window-content");
|
||||||
|
contentWrapper.appendChild(contentElement);
|
||||||
|
|
||||||
|
window.appendChild(header);
|
||||||
|
window.appendChild(contentWrapper);
|
||||||
|
|
||||||
document.body.appendChild(window);
|
document.body.appendChild(window);
|
||||||
makeDraggable(window.querySelector(".birb-window-header"));
|
makeDraggable(header);
|
||||||
|
|
||||||
const closeButton = window.querySelector(".birb-window-close");
|
|
||||||
if (closeButton) {
|
|
||||||
makeClosable(() => {
|
makeClosable(() => {
|
||||||
window.remove();
|
window.remove();
|
||||||
}, closeButton);
|
}, closeButton);
|
||||||
}
|
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
@@ -2031,7 +2040,13 @@
|
|||||||
function unlockBird(birdType) {
|
function unlockBird(birdType) {
|
||||||
if (!unlockedSpecies.includes(birdType)) {
|
if (!unlockedSpecies.includes(birdType)) {
|
||||||
unlockedSpecies.push(birdType);
|
unlockedSpecies.push(birdType);
|
||||||
insertModal("New Bird Unlocked!", `You've found a <b>${SPECIES[birdType].name}</b> feather! Use the Field Guide to switch your bird's species.`);
|
const message = makeElement("birb-message-content");
|
||||||
|
message.appendChild(document.createTextNode("You've found a "));
|
||||||
|
const bold = document.createElement("b");
|
||||||
|
bold.textContent = SPECIES[birdType].name;
|
||||||
|
message.appendChild(bold);
|
||||||
|
message.appendChild(document.createTextNode(" feather! Use the Field Guide to switch your bird's species."));
|
||||||
|
insertModal("New Bird Unlocked!", message);
|
||||||
}
|
}
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
@@ -2058,18 +2073,14 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} title
|
* @param {string} title
|
||||||
* @param {string} message
|
* @param {HTMLElement} content
|
||||||
*/
|
*/
|
||||||
function insertModal(title, message) {
|
function insertModal(title, content) {
|
||||||
if (document.querySelector("#" + FIELD_GUIDE_ID)) {
|
if (document.querySelector("#" + FIELD_GUIDE_ID)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const modal = createWindow("birb-modal", title, `
|
const modal = createWindow("birb-modal", title, content);
|
||||||
<div class="birb-message-content">
|
|
||||||
${message}
|
|
||||||
</div>
|
|
||||||
`);
|
|
||||||
|
|
||||||
modal.style.width = "270px";
|
modal.style.width = "270px";
|
||||||
centerElement(modal);
|
centerElement(modal);
|
||||||
@@ -2104,30 +2115,39 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const contentContainer = document.createElement("div");
|
||||||
|
const content = makeElement("birb-grid-content");
|
||||||
|
const description = makeElement("birb-field-guide-description");
|
||||||
|
contentContainer.appendChild(content);
|
||||||
|
contentContainer.appendChild(description);
|
||||||
|
|
||||||
const fieldGuide = createWindow(
|
const fieldGuide = createWindow(
|
||||||
FIELD_GUIDE_ID,
|
FIELD_GUIDE_ID,
|
||||||
"Field Guide",
|
"Field Guide",
|
||||||
`<div class="birb-grid-content"></div>
|
contentContainer
|
||||||
<div class="birb-field-guide-description"></div>`
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const content = fieldGuide.querySelector(".birb-grid-content");
|
|
||||||
if (!content) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
content.innerHTML = "";
|
|
||||||
|
|
||||||
const generateDescription = (/** @type {string} */ speciesId) => {
|
const generateDescription = (/** @type {string} */ speciesId) => {
|
||||||
const type = SPECIES[speciesId];
|
const type = SPECIES[speciesId];
|
||||||
const unlocked = unlockedSpecies.includes(speciesId);
|
const unlocked = unlockedSpecies.includes(speciesId);
|
||||||
return "<b>" + type.name + "</b><div style='height: 0.3em'></div>" + (!unlocked ? "Not yet unlocked" : type.description);
|
|
||||||
|
const boldName = document.createElement("b");
|
||||||
|
boldName.textContent = type.name;
|
||||||
|
|
||||||
|
const spacer = document.createElement("div");
|
||||||
|
spacer.style.height = "0.3em";
|
||||||
|
|
||||||
|
const descText = document.createTextNode(!unlocked ? "Not yet unlocked" : type.description);
|
||||||
|
|
||||||
|
const fragment = document.createDocumentFragment();
|
||||||
|
fragment.appendChild(boldName);
|
||||||
|
fragment.appendChild(spacer);
|
||||||
|
fragment.appendChild(descText);
|
||||||
|
|
||||||
|
return fragment;
|
||||||
};
|
};
|
||||||
|
|
||||||
const description = fieldGuide.querySelector(".birb-field-guide-description");
|
description.appendChild(generateDescription(currentSpecies));
|
||||||
if (!description) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
description.innerHTML = generateDescription(currentSpecies);
|
|
||||||
for (const [id, type] of Object.entries(SPECIES)) {
|
for (const [id, type] of Object.entries(SPECIES)) {
|
||||||
const unlocked = unlockedSpecies.includes(id);
|
const unlocked = unlockedSpecies.includes(id);
|
||||||
const speciesElement = makeElement("birb-grid-item");
|
const speciesElement = makeElement("birb-grid-item");
|
||||||
@@ -2156,10 +2176,12 @@
|
|||||||
speciesElement.classList.add("birb-grid-item-locked");
|
speciesElement.classList.add("birb-grid-item-locked");
|
||||||
}
|
}
|
||||||
speciesElement.addEventListener("mouseover", () => {
|
speciesElement.addEventListener("mouseover", () => {
|
||||||
description.innerHTML = generateDescription(id);
|
description.textContent = "";
|
||||||
|
description.appendChild(generateDescription(id));
|
||||||
});
|
});
|
||||||
speciesElement.addEventListener("mouseout", () => {
|
speciesElement.addEventListener("mouseout", () => {
|
||||||
description.innerHTML = generateDescription(currentSpecies);
|
description.textContent = "";
|
||||||
|
description.appendChild(generateDescription(currentSpecies));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
centerElement(fieldGuide);
|
centerElement(fieldGuide);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "Pocket Bird",
|
"name": "Pocket Bird",
|
||||||
"description": "It's a bird, in your browser. What more could you want?",
|
"description": "It's a bird, in your browser. What more could you want?",
|
||||||
"version": "2025.10.26.500",
|
"version": "2025.10.26.536",
|
||||||
"homepage_url": "https://idreesinc.com",
|
"homepage_url": "https://idreesinc.com",
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -215,7 +215,14 @@ Promise.all([
|
|||||||
new MenuItem("Toggle Birb Mode", () => {
|
new MenuItem("Toggle Birb Mode", () => {
|
||||||
userSettings.birbMode = !userSettings.birbMode;
|
userSettings.birbMode = !userSettings.birbMode;
|
||||||
save();
|
save();
|
||||||
insertModal(`${birdBirb()} Mode`, `Your ${birdBirb().toLowerCase()} shall now be referred to as "${birdBirb()}"${userSettings.birbMode ? "\n\nWelcome back to 2012" : ""}`);
|
const message = makeElement("birb-message-content");
|
||||||
|
message.appendChild(document.createTextNode(`Your ${birdBirb().toLowerCase()} shall now be referred to as "${birdBirb()}"`));
|
||||||
|
if (userSettings.birbMode) {
|
||||||
|
message.appendChild(document.createElement("br"));
|
||||||
|
message.appendChild(document.createElement("br"));
|
||||||
|
message.appendChild(document.createTextNode("Welcome back to 2012"));
|
||||||
|
}
|
||||||
|
insertModal(`${birdBirb()} Mode`, message);
|
||||||
}),
|
}),
|
||||||
new Separator(),
|
new Separator(),
|
||||||
new MenuItem("__VERSION__", () => { alert("Thank you for using Pocket Bird! You are on version: __VERSION__") }, false),
|
new MenuItem("__VERSION__", () => { alert("Thank you for using Pocket Bird! You are on version: __VERSION__") }, false),
|
||||||
@@ -552,34 +559,37 @@ Promise.all([
|
|||||||
* Create a window element with header and content
|
* Create a window element with header and content
|
||||||
* @param {string} id
|
* @param {string} id
|
||||||
* @param {string} title
|
* @param {string} title
|
||||||
* @param {string} contentHtml
|
* @param {HTMLElement} contentElement
|
||||||
* @param {() => void} [onClose]
|
* @param {() => void} [onClose]
|
||||||
* @returns {HTMLElement}
|
* @returns {HTMLElement}
|
||||||
*/
|
*/
|
||||||
function createWindow(id, title, contentHtml, onClose) {
|
function createWindow(id, title, contentElement, onClose) {
|
||||||
const window = makeElement("birb-window", undefined, id);
|
const window = makeElement("birb-window", undefined, id);
|
||||||
window.innerHTML = `
|
|
||||||
<div class="birb-window-header">
|
const header = makeElement("birb-window-header");
|
||||||
<div class="birb-window-title">${title}</div>
|
const titleElement = makeElement("birb-window-title");
|
||||||
<div class="birb-window-close">x</div>
|
titleElement.textContent = title;
|
||||||
</div>
|
const closeButton = makeElement("birb-window-close");
|
||||||
<div class="birb-window-content">
|
closeButton.textContent = "x";
|
||||||
${contentHtml}
|
|
||||||
</div>
|
header.appendChild(titleElement);
|
||||||
`;
|
header.appendChild(closeButton);
|
||||||
|
|
||||||
|
const contentWrapper = makeElement("birb-window-content");
|
||||||
|
contentWrapper.appendChild(contentElement);
|
||||||
|
|
||||||
|
window.appendChild(header);
|
||||||
|
window.appendChild(contentWrapper);
|
||||||
|
|
||||||
document.body.appendChild(window);
|
document.body.appendChild(window);
|
||||||
makeDraggable(window.querySelector(".birb-window-header"));
|
makeDraggable(header);
|
||||||
|
|
||||||
const closeButton = window.querySelector(".birb-window-close");
|
|
||||||
if (closeButton) {
|
|
||||||
makeClosable(() => {
|
makeClosable(() => {
|
||||||
if (onClose) {
|
if (onClose) {
|
||||||
onClose();
|
onClose();
|
||||||
}
|
}
|
||||||
window.remove();
|
window.remove();
|
||||||
}, closeButton);
|
}, closeButton);
|
||||||
}
|
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
@@ -639,7 +649,13 @@ Promise.all([
|
|||||||
function unlockBird(birdType) {
|
function unlockBird(birdType) {
|
||||||
if (!unlockedSpecies.includes(birdType)) {
|
if (!unlockedSpecies.includes(birdType)) {
|
||||||
unlockedSpecies.push(birdType);
|
unlockedSpecies.push(birdType);
|
||||||
insertModal("New Bird Unlocked!", `You've found a <b>${SPECIES[birdType].name}</b> feather! Use the Field Guide to switch your bird's species.`);
|
const message = makeElement("birb-message-content");
|
||||||
|
message.appendChild(document.createTextNode("You've found a "));
|
||||||
|
const bold = document.createElement("b");
|
||||||
|
bold.textContent = SPECIES[birdType].name;
|
||||||
|
message.appendChild(bold);
|
||||||
|
message.appendChild(document.createTextNode(" feather! Use the Field Guide to switch your bird's species."));
|
||||||
|
insertModal("New Bird Unlocked!", message);
|
||||||
}
|
}
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
@@ -666,18 +682,14 @@ Promise.all([
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} title
|
* @param {string} title
|
||||||
* @param {string} message
|
* @param {HTMLElement} content
|
||||||
*/
|
*/
|
||||||
function insertModal(title, message) {
|
function insertModal(title, content) {
|
||||||
if (document.querySelector("#" + FIELD_GUIDE_ID)) {
|
if (document.querySelector("#" + FIELD_GUIDE_ID)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const modal = createWindow("birb-modal", title, `
|
const modal = createWindow("birb-modal", title, content);
|
||||||
<div class="birb-message-content">
|
|
||||||
${message}
|
|
||||||
</div>
|
|
||||||
`);
|
|
||||||
|
|
||||||
modal.style.width = "270px";
|
modal.style.width = "270px";
|
||||||
centerElement(modal);
|
centerElement(modal);
|
||||||
@@ -713,30 +725,39 @@ Promise.all([
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const contentContainer = document.createElement("div");
|
||||||
|
const content = makeElement("birb-grid-content");
|
||||||
|
const description = makeElement("birb-field-guide-description");
|
||||||
|
contentContainer.appendChild(content);
|
||||||
|
contentContainer.appendChild(description);
|
||||||
|
|
||||||
const fieldGuide = createWindow(
|
const fieldGuide = createWindow(
|
||||||
FIELD_GUIDE_ID,
|
FIELD_GUIDE_ID,
|
||||||
"Field Guide",
|
"Field Guide",
|
||||||
`<div class="birb-grid-content"></div>
|
contentContainer
|
||||||
<div class="birb-field-guide-description"></div>`
|
);
|
||||||
)
|
|
||||||
|
|
||||||
const content = fieldGuide.querySelector(".birb-grid-content");
|
|
||||||
if (!content) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
content.innerHTML = "";
|
|
||||||
|
|
||||||
const generateDescription = (/** @type {string} */ speciesId) => {
|
const generateDescription = (/** @type {string} */ speciesId) => {
|
||||||
const type = SPECIES[speciesId];
|
const type = SPECIES[speciesId];
|
||||||
const unlocked = unlockedSpecies.includes(speciesId);
|
const unlocked = unlockedSpecies.includes(speciesId);
|
||||||
return "<b>" + type.name + "</b><div style='height: 0.3em'></div>" + (!unlocked ? "Not yet unlocked" : type.description);
|
|
||||||
|
const boldName = document.createElement("b");
|
||||||
|
boldName.textContent = type.name;
|
||||||
|
|
||||||
|
const spacer = document.createElement("div");
|
||||||
|
spacer.style.height = "0.3em";
|
||||||
|
|
||||||
|
const descText = document.createTextNode(!unlocked ? "Not yet unlocked" : type.description);
|
||||||
|
|
||||||
|
const fragment = document.createDocumentFragment();
|
||||||
|
fragment.appendChild(boldName);
|
||||||
|
fragment.appendChild(spacer);
|
||||||
|
fragment.appendChild(descText);
|
||||||
|
|
||||||
|
return fragment;
|
||||||
};
|
};
|
||||||
|
|
||||||
const description = fieldGuide.querySelector(".birb-field-guide-description");
|
description.appendChild(generateDescription(currentSpecies));
|
||||||
if (!description) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
description.innerHTML = generateDescription(currentSpecies);
|
|
||||||
for (const [id, type] of Object.entries(SPECIES)) {
|
for (const [id, type] of Object.entries(SPECIES)) {
|
||||||
const unlocked = unlockedSpecies.includes(id);
|
const unlocked = unlockedSpecies.includes(id);
|
||||||
const speciesElement = makeElement("birb-grid-item");
|
const speciesElement = makeElement("birb-grid-item");
|
||||||
@@ -765,10 +786,12 @@ Promise.all([
|
|||||||
speciesElement.classList.add("birb-grid-item-locked");
|
speciesElement.classList.add("birb-grid-item-locked");
|
||||||
}
|
}
|
||||||
speciesElement.addEventListener("mouseover", () => {
|
speciesElement.addEventListener("mouseover", () => {
|
||||||
description.innerHTML = generateDescription(id);
|
description.textContent = "";
|
||||||
|
description.appendChild(generateDescription(id));
|
||||||
});
|
});
|
||||||
speciesElement.addEventListener("mouseout", () => {
|
speciesElement.addEventListener("mouseout", () => {
|
||||||
description.innerHTML = generateDescription(currentSpecies);
|
description.textContent = "";
|
||||||
|
description.appendChild(generateDescription(currentSpecies));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
centerElement(fieldGuide);
|
centerElement(fieldGuide);
|
||||||
|
|||||||
@@ -243,8 +243,8 @@
|
|||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
padding-right: 10px;
|
padding-right: 10px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
justify-content: start;
|
justify-content: center;
|
||||||
align-items: start;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.birb-grid-item {
|
.birb-grid-item {
|
||||||
@@ -289,6 +289,7 @@
|
|||||||
|
|
||||||
.birb-field-guide-description {
|
.birb-field-guide-description {
|
||||||
width: calc(100% - 20px);
|
width: calc(100% - 20px);
|
||||||
|
margin-left: 10px;
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
padding-top: 4px;
|
padding-top: 4px;
|
||||||
@@ -305,11 +306,9 @@
|
|||||||
|
|
||||||
.birb-message-content {
|
.birb-message-content {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
margin: 2px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-top: 10px;
|
padding: 10px;
|
||||||
padding: 8px;
|
|
||||||
padding-top: 4px;
|
|
||||||
padding-bottom: 4px;
|
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: rgb(124, 108, 75);
|
color: rgb(124, 108, 75);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user