Last active
April 1, 2023 01:52
-
-
Save azu/b1a9dcd57eb6e738844cd477843eb09f to your computer and use it in GitHub Desktop.
irodr: 4/1 april fool filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name irodr: 4/1 april fool filter | |
// @namespace irodr.netlify.com.april-contents | |
// @description NG content and replace dummy content when match NGList | |
// @include https://irodr.netlify.app/ | |
// @version 1 | |
// @grant none | |
// @run-at document-end | |
// ==/UserScript== | |
const AprilFoolRegs = [/4\-1/, /4\/1/, /[44]月[11]日/, /April.*?Fool/i, /エイプリル/, /嘘/, /フール/, /April Dream/]; | |
const NGList = [ | |
{ | |
title: AprilFoolRegs | |
}, | |
{ | |
body: AprilFoolRegs | |
} | |
]; | |
setTimeout(() => { | |
userScript.event.subscribe("SubscriptionContent::componentDidMount", content => { | |
const isMatchAnyNG = NGList.some(NGItem => { | |
let isNG = false; | |
if (NGItem.title) { | |
isNG = NGItem.title.some(reg => reg.test(content.title)); | |
} | |
if (NGItem.body) { | |
isNG = NGItem.body.some(reg => reg.test(content.body)) | |
} | |
if (NGItem.url) { | |
isNG = NGItem.url.some(reg => reg.test(content.url)) | |
} | |
return isNG; | |
}); | |
if (!isMatchAnyNG) { | |
return; | |
} | |
const element = document.querySelector(`[data-content-id="${content.contentId}"]`); | |
if (element) { | |
element.querySelector(".SubscriptionContentsContainer-contentTitle").classList.add("ng-content"); | |
element.querySelector(".SubscriptionContentsContainer-contentTitle").classList.add("ng-april"); | |
element.querySelector(".SubscriptionContentsContainer-contentBody").setAttribute("hidden", ""); | |
} | |
}); | |
},1000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment