2019-05-22 01:22:58 +00:00
|
|
|
// Search button function
|
2020-03-20 05:37:09 +00:00
|
|
|
document.getElementById('search-click').addEventListener('click', () => {
|
2019-06-07 09:09:51 +00:00
|
|
|
searchForm.submit()
|
|
|
|
}, false)
|
2019-06-01 09:21:51 +00:00
|
|
|
|
2020-03-20 05:37:09 +00:00
|
|
|
document.getElementById('search-click-mobile').addEventListener('click', () => {
|
2019-08-10 14:39:23 +00:00
|
|
|
searchFormMob.submit()
|
2019-06-01 09:21:51 +00:00
|
|
|
}, false)
|
2020-03-06 08:47:37 +00:00
|
|
|
|
2020-03-20 05:18:36 +00:00
|
|
|
// Web Share API
|
|
|
|
// https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share
|
|
|
|
// Only available on supporting browsers and HTTPS
|
|
|
|
if (navigator.share && document.location.protocol === 'https:') {
|
|
|
|
document.getElementById('share-click').addEventListener('click', async () => {
|
|
|
|
const query = (selector) => {
|
|
|
|
return document.querySelector(selector)
|
|
|
|
}
|
|
|
|
|
|
|
|
const title = query('meta[property="og:title"]') ? query('meta[property="og:title"]').content : ''
|
|
|
|
const text = query('meta[property="og:description"]') ? query('meta[property="og:description"]').content : ''
|
|
|
|
const url = query('link[rel="canonical"]') ? query('link[rel="canonical"]').href : document.location.href
|
|
|
|
|
|
|
|
await navigator.share({ title, text, url })
|
|
|
|
}, false)
|
|
|
|
}
|
|
|
|
|
2020-03-06 08:47:37 +00:00
|
|
|
// Use duckduckgo's onion address when the site is accessed via .onion
|
|
|
|
if (document.location.hostname.endsWith('.onion')) {
|
|
|
|
const searchForms = document.querySelectorAll('form#searchForm, form#searchFormMob')
|
|
|
|
|
|
|
|
searchForms.forEach((form) => {
|
|
|
|
form.setAttribute('action', 'https://3g2upl4pq6kufc4m.onion/')
|
|
|
|
})
|
|
|
|
}
|