MediaWiki:Gadget-warn-archive-today.js
跳转到导航
跳转到搜索
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
/**
* 临时措施,在访问archive.today系列网站时显示警告
* [[Wikipedia:互助客栈/其他#Archive.today二三事]]
* [[:en:Wikipedia:Requests_for_comment/Archive.is_RFC_5]]
**/
( async () => {
const { conv } = require( 'ext.gadget.HanAssist' );
// [[Special:AbuseFilter/393]]
const archiveRegex =
/^https?:\/\/archive(?:\.(?:fo|is|li|md|ph|today|vn)\b|iya74codqgiixo33q62qlrqtkgmcitqx5u2oeqnmn5bpcbiyd\.onion)\b/i;
document.addEventListener( 'click', async ( event ) => {
const link = event.target.closest( 'a.external' );
if ( !link ) {
return;
}
const url = link.getAttribute( 'href' );
if ( url && archiveRegex.test( url ) ) {
event.preventDefault();
const isConfirmed = await OO.ui.confirm(
conv( {
hans: '该外部网站存在已知安全问题,如非必要,请勿访问。是否仍要访问?',
hant: '該外部網站存在已知安全問題,如非必要,請勿訪問。是否仍要訪問?',
} ),
{
title: '安全警告',
},
);
if ( isConfirmed ) {
const target = link.getAttribute( 'target' ) || '_self';
if ( target === '_blank' ) {
window.open( url, '_blank' );
} else {
window.location.href = url;
}
}
}
}, { capture: true } );
} )();