Skip to content

Instantly share code, notes, and snippets.

@pingyen
Created October 1, 2024 18:00
Show Gist options
  • Save pingyen/5fc3ddb3729a3d8852f66fe4b1db29d0 to your computer and use it in GitHub Desktop.
Save pingyen/5fc3ddb3729a3d8852f66fe4b1db29d0 to your computer and use it in GitHub Desktop.
PTT over 18 cookie detection
(() => {
const set = new Set(['gossiping', 'sex']);
const pathname = location.pathname;
const tokens = pathname.split('/');
if (tokens.length < 3) {
return;
}
const kind = tokens[1];
if (kind !== 'bbs' && kind !== 'man') {
return;
}
const board = tokens[2].toLocaleLowerCase();
if (set.has(board) === false) {
return;
}
if (document.cookie.indexOf('over18=1') !== -1) {
return;
}
location.replace('/ask/over18?from=' + encodeURIComponent(pathname));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment