47 lines
1.8 KiB
JavaScript
47 lines
1.8 KiB
JavaScript
|
document.querySelector('#search-form').addEventListener('submit', (event) => {
|
||
|
event.preventDefault();
|
||
|
console.log("Submit Triggered");
|
||
|
const searchInput = document.querySelector("#search-field").value;
|
||
|
console.log(searchInput);
|
||
|
let queryPlus = searchInput.replace(/ /g, '+');
|
||
|
console.log(queryPlus);
|
||
|
let queryUnderscore = searchInput.replace(/ /g, '_');
|
||
|
console.log(queryUnderscore);
|
||
|
if (searchInput.startsWith("/")) {
|
||
|
console.log('Slash Command Triggered');
|
||
|
if (searchInput.startsWith("/c")) {
|
||
|
let initialChargeSearch = "https://initialcharge.net/?s=" + queryPlus.replace('/c+', '');
|
||
|
console.log(initialChargeSearch);
|
||
|
window.location.href = initialChargeSearch;
|
||
|
}
|
||
|
if (searchInput.startsWith("/i")) {
|
||
|
let invidiousSearch = "https://video.libertynode.org/search?q=" + queryPlus.replace('/i+', '');
|
||
|
console.log(invidiousSearch);
|
||
|
window.location.href = invidiousSearch;
|
||
|
}
|
||
|
if (searchInput.startsWith("/o")) {
|
||
|
let odyseeSearch = "https://odysee.com/$/search?q=" + queryPlus.replace('/o+', '');
|
||
|
console.log(odyseeSearch);
|
||
|
window.location.href = odyseeSearch;
|
||
|
}
|
||
|
if (searchInput.startsWith("/p")) {
|
||
|
let podcastSearch = "https://podcastindex.org/search?q=" + queryPlus.replace('/p+', '');
|
||
|
console.log(podcastSearch);
|
||
|
window.location.href = podcastSearch;
|
||
|
}
|
||
|
if (searchInput.startsWith("/s")) {
|
||
|
let songSearch = "https://odesli.co/?q=" + queryPlus.replace('/s+', '');
|
||
|
console.log(songSearch);
|
||
|
window.location.href = songSearch;
|
||
|
}
|
||
|
if (searchInput.startsWith("/t")) {
|
||
|
let tpbSearch = "https://thepiratebay.org/search.php?q=" + queryPlus.replace('/t+', '');
|
||
|
console.log(tpbSearch);
|
||
|
window.location.href = tpbSearch;
|
||
|
}
|
||
|
} else {
|
||
|
let braveSearch = "https://search.brave.com/search?q=%s".replace('%s', queryPlus);
|
||
|
console.log(braveSearch);
|
||
|
window.location.href = braveSearch;
|
||
|
}
|
||
|
})
|