-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
irodr-ng-content.user.js
48 lines (48 loc) · 1.43 KB
/
irodr-ng-content.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// ==UserScript==
// @name irodir: ng contents
// @namespace irodr.netlify.app.ng-contents
// @description NG content and replace dummy content when match NGList
// @include http://irodr.netlify.app/
// @include https://irodr.netlify.app/
// @include http://localhost:13245/
// @version 1
// @grant none
// @run-at document-end
// ==/UserScript==
"use strict";
const NGList = [
{
title: /^AD:/
},
{
title: /^PR:/
},
{
title: /^\[AD]/
}
// {
// url: /^http:\/\/block.example.com\//
// }
];
window.addEventListener("userscript-init", () => {
userScript.event.subscribe("SubscriptionContent::componentDidMount", (content) => {
const isMatchAnyNG = NGList.some((NGItem) => {
let isNG = false;
if (NGItem.title) {
isNG = NGItem.title.test(content.title);
}
if (NGItem.url) {
isNG = NGItem.url.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-contentBody").setAttribute("hidden", "");
}
});
});