Skip to content

Instantly share code, notes, and snippets.

@crashmax-dev
Created September 5, 2024 16:37
Show Gist options
  • Save crashmax-dev/ff76d24d1d2ce321234708675a753ddd to your computer and use it in GitHub Desktop.
Save crashmax-dev/ff76d24d1d2ce321234708675a753ddd to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name reyohoho-extended
// @version 0.0.0
// @license MIT
// @homepage https://github.com/crashmax-dev/reyohoho-extended
// @match https://reyohoho.github.io/reyohoho/*
// @updateURL https://github.com/crashmax-dev/reyohoho-extended.meta.js
// @downloadURL https://github.com/crashmax-dev/reyohoho-extended.user.js
// ==/UserScript==
(function(){"use strict";function c(i){return Object.entries(i)}const u=(i,e)=>i;class a{#s;#e;#t;constructor({encode:e=u,decode:s=u,attributes:n={},initialValue:t}={}){if(this.#s=e,this.#e=s,this.attributes=n,t)for(const[o,r]of c(t))this.has(o)||this.set(o,r)}get attributes(){return this.#t}set attributes(e){this.#t=e}get(e){const s=`; ${document.cookie}`.match(`;\\s*${e}=([^;]+)`);return s?this.#e(decodeURIComponent(s[1]),e):null}set(e,s,n){const t={path:"/",...this.#t,...n};typeof t.expires=="number"&&(t.expires=new Date(Date.now()+t.expires*864e5)),t.expires instanceof Date&&(t.expires=t.expires.toUTCString());let o=`${encodeURIComponent(e)}=${encodeURIComponent(this.#s(s,e))}`;for(const[r,h]of c(t))o+=`; ${r}`,h!==!0&&(o+=`=${h}`);document.cookie=o}list(){const e=document.cookie,s=(e?e.split("; "):[]).map(n=>{const[t,o]=n.split(/=(.*)/);return[t,this.#e(decodeURIComponent(o),t)]});return Object.fromEntries(s)}remove(e,s){this.set(e,null,{...s,expires:-1})}has(e){return!!this.get(e)}}new a().remove("_searches")})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment