Skip to content

Commit

Permalink
Update unlimited.js
Browse files Browse the repository at this point in the history
Code Refactoring
  • Loading branch information
fl2on authored May 23, 2024
1 parent f5fec6c commit d12d8dd
Showing 1 changed file with 12 additions and 40 deletions.
52 changes: 12 additions & 40 deletions unlimited.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,66 +9,38 @@
async function removeCharLimit() {
try {
const searchInput = document.querySelector("#sb_form_q");
if (searchInput) {
searchInput.removeAttribute("maxlength");
} else {
console.error("Entrada de búsqueda no encontrada.");
}
if (searchInput) searchInput.removeAttribute("maxlength");

const elementToRemove = document.querySelector("#sb_chcounter_r");
if (elementToRemove) {
elementToRemove.remove();
} else {
console.warn("Elemento con ID 'sb_chcounter_r' no encontrado.");
}
document.querySelector("#sb_chcounter_r")?.remove();

const serp = document.querySelector("#b_sydConvCont > cib-serp");
if (!serp) throw new Error("Elemento cib-serp no encontrado.");

if (!serp) {
throw new Error("Elemento cib-serp no encontrado.");
}

const serpShadowRoot = serp.shadowRoot;
const actionBarMain = serpShadowRoot.querySelector("#cib-action-bar-main");

if (!actionBarMain) {
throw new Error("Elemento cib-action-bar-main no encontrado.");
}

const actionBarMainShadowRoot = actionBarMain.shadowRoot;
const textInput = actionBarMainShadowRoot.querySelector("div > div.main-container > div > div.input-row > cib-text-input");

if (!textInput) {
throw new Error("Elemento cib-text-input no encontrado.");
}
const actionBarMain = serp.shadowRoot.querySelector("#cib-action-bar-main");
if (!actionBarMain) throw new Error("Elemento cib-action-bar-main no encontrado.");

const textInputShadowRoot = textInput.shadowRoot;
const textarea = textInputShadowRoot.querySelector("#searchbox");
const textInput = actionBarMain.shadowRoot.querySelector("div > div.main-container > div > div.input-row > cib-text-input");
if (!textInput) throw new Error("Elemento cib-text-input no encontrado.");

const textarea = textInput.shadowRoot.querySelector("#searchbox");
if (textarea) {
textarea.removeAttribute("maxlength");
textarea.setAttribute("aria-description", "∞");
} else {
throw new Error("Textarea con atributo 'maxlength' no encontrado.");
}

const letterCounter = actionBarMainShadowRoot.querySelector("div > div.main-container > div > div.bottom-controls > div.bottom-right-controls > div.letter-counter");
const letterCounter = actionBarMain.shadowRoot.querySelector("div > div.main-container > div > div.bottom-controls > div.bottom-right-controls > div.letter-counter");
if (letterCounter) letterCounter.textContent = "∞";

if (letterCounter) {
letterCounter.textContent = "∞";
} else {
console.warn("Elemento .letter-counter no encontrado.");
}
} catch (error) {
console.error("Error:", error.message);
}
}

async function initializeExtension() {
removeCharLimit();
}
const initializeExtension = () => removeCharLimit();

const interval = setInterval(initializeExtension, 3000);
setInterval(initializeExtension, 3000);
window.addEventListener("load", initializeExtension);
window.addEventListener("popstate", initializeExtension);
})();

0 comments on commit d12d8dd

Please sign in to comment.