Yapa: Eliminar JavaScript extra

This commit is contained in:
f 2021-09-17 15:42:57 -03:00
parent 43cee04527
commit 5be70267cb
2 changed files with 5 additions and 44 deletions

View file

@ -32,6 +32,11 @@ try {
if (window.axe) window.axe.configure({ locale: require('axe-core/locales/es.json') }) if (window.axe) window.axe.configure({ locale: require('axe-core/locales/es.json') })
document.addEventListener('turbo:load', event => { document.addEventListener('turbo:load', event => {
document.querySelectorAll("a[href^='http://'],a[href^='https://'],a[href^='//']").forEach(a => {
a.rel = "noopener"
a.target = "_blank"
})
if (!window.axe) return if (!window.axe) return
window.axe.run().then(results => { window.axe.run().then(results => {

View file

@ -1,44 +0,0 @@
---
---
const loadEvent = () => {
try {
if (Turbolinks) return 'turbolinks:load'
} catch {
return 'DOMContentLoaded'
}
}
document.addEventListener(loadEvent(), () => {
document.querySelectorAll('.share').forEach(share => {
share.addEventListener('click', event => {
if (!Navigator.share) return;
event.preventDefault();
event.stopPropagation();
const title = document.querySelector('title').text;
try {
const text = document.querySelector('meta[property="og:description"]').content;
} catch {
const text = '';
}
try {
const url = document.querySelector('link[rel=canonical]').href;
} catch {
const url = document.location.href;
}
const data = { title: title, text: text, url: url };
if (Navigator.canShare(data)) Navigator.share(data).then();
});
});
document.querySelectorAll("a[href^='http://'],a[href^='https://'],a[href^='//']").forEach(a => {
a.rel = "noopener";
a.target = "_blank";
});
});