Skip to content

Instantly share code, notes, and snippets.

@BienGudBoy
Created April 13, 2025 12:44
Show Gist options
  • Save BienGudBoy/02f19d953b19d354fa329e3f6b3d2c7a to your computer and use it in GitHub Desktop.
Save BienGudBoy/02f19d953b19d354fa329e3f6b3d2c7a to your computer and use it in GitHub Desktop.
Auto set over18 cookie on Reddit
// ==UserScript==
// @name Auto set over18 cookie on Reddit
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Automatically sets the "over18" cookie to 1 on Reddit to bypass age verification
// @author You
// @match https://www.reddit.com/*
// @match https://old.reddit.com/*
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
(function() {
'use strict';
function setOver18Cookie() {
document.cookie = "over18=1; path=/; domain=reddit.com; expires=" + new Date(Date.now() + 365*24*60*60*1000).toUTCString();
}
function getOver18Cookie() {
let name = "over18=";
let decodedCookie = decodeURIComponent(document.cookie);
let ca = decodedCookie.split(';');
for(let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return true; // over18 cookie exists
}
}
return false; // over18 cookie doesn't exist
}
if ((window.location.hostname === 'www.reddit.com' || window.location.hostname === 'old.reddit.com') && !getOver18Cookie()) {
setOver18Cookie();
window.location.reload();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment