Skip to content

Commit

Permalink
Merge pull request #120 from fireblocks/SlavaSereb-patch-45
Browse files Browse the repository at this point in the history
Update scalar-api-interaction.js
  • Loading branch information
SlavaSereb authored Nov 26, 2024
2 parents 36f70ac + 936f50f commit ba1a674
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions scalar-api-interaction.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
(function() {
console.log("Script loaded and running...");

// Function to hide the specified element
function hideElement() {
let elementsToHide = [];
elementsToHide.push(document.querySelector('#app > div.api-references-layout > div.scalar-app.scalar-api-reference.references-layout.references-sidebar.references-sidebar-mobile-open > section > div.narrow-references-container > div:nth-child(2) > section > div > div > div:nth-child(2) > div > div > div:nth-child(2)'));
elementsToHide.push(document.querySelector('#app > div.api-references-layout > div.scalar-app.scalar-api-reference.references-layout.references-sidebar.references-sidebar-mobile-open > section > div.narrow-references-container > div:nth-child(2) > section > div > div > div:nth-child(2) > div > div > div:nth-child(3)'));

if (elementsToHide) {
elementsToHide.forEach( (elementToHide) => {
let elementsToHide = [];
elementsToHide.push(document.querySelector('#app > div.api-references-layout > div.scalar-app.scalar-api-reference.references-layout.references-sidebar.references-sidebar-mobile-open > section > div.narrow-references-container > div:nth-child(2) > section > div > div > div:nth-child(2) > div > div > div:nth-child(2)'));
elementsToHide.push(document.querySelector('#app > div.api-references-layout > div.scalar-app.scalar-api-reference.references-layout.references-sidebar.references-sidebar-mobile-open > section > div.narrow-references-container > div:nth-child(2) > section > div > div > div:nth-child(2) > div > div > div:nth-child(3)'));

elementsToHide
.filter(element => element !== null)
.forEach(elementToHide => {
elementToHide.style.display = 'none';
console.log("Element hidden successfully");
})
}
}
});
}

// Hide element immediately
hideElement();
setTimeout( () => {
hideElement();
}, 3000)

// Function to handle route changes
function handleRouteChange() {
console.log("Route change detected");
// Remove existing injected elements to avoid duplicates
const existingContainer = document.getElementById('custom-input-container');
if (existingContainer) {
existingContainer.remove();
}
// Hide element after route change
hideElement();
// Re-run the injection process
injectFields();
}

// Set up route observer using different methods to ensure we catch the change

// 1. Watch for URL changes
let lastUrl = location.href;
Expand Down Expand Up @@ -434,10 +430,8 @@
}
};

// Start the injection process with a slight delay
console.log("Setting up initial injection...");
setTimeout(() => {
hideElement(); // Hide element again after delay
injectFields();
}, 1000);
})();

0 comments on commit ba1a674

Please sign in to comment.