微件:沙盒:修订间差异
来自NMWiki
更多操作
Smalllqiang(留言 | 贡献) |
Smalllqiang(留言 | 贡献) |
||
| (未显示同一用户的7个中间版本) | |||
| 第1行: | 第1行: | ||
<includeonly> | <includeonly> | ||
<script> | <script type="text/javascript" src="https://code.jquery.com/jquery-3.6.0.min.js"></script> | ||
<script type="text/javascript"> | |||
$(function() { | $(function() { | ||
if (document.cookie.includes('age_rank_accept=True')) { | |||
return; | |||
} | |||
mw.loader.using('oojs-ui').then(function() { | |||
const dialog = new OO.ui.MessageDialog(); | |||
const windowManager = new OO.ui.WindowManager(); | |||
$('body').append(windowManager.$element); | |||
windowManager.addWindows([dialog]); | |||
const message = $('<div>') | |||
.append('警告,本页面含有R15内容。'); | |||
windowManager.openWindow(dialog, { | |||
title: '年龄分级警告', | |||
message: message, | |||
actions: [{ | |||
action: 'accept', | |||
label: '我不在意任何年龄分级且 1 天内不再提示', | |||
}, { | |||
action: 'return', | |||
label: '返回上一页', | |||
}] | |||
}).closed.then(function(data) { | |||
if (data.action === 'accept') { | |||
const date = new Date(); | |||
date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000)); | |||
const expires = "expires=" + date.toUTCString(); | |||
document.cookie = "age_rank_accept=True;" + expires + ";path=/"; | |||
} else if (data.action === 'return') { | |||
history.back(); | |||
} | |||
}); | |||
}); | |||
}); | }); | ||
</script> | </script> | ||
</includeonly> | </includeonly> | ||