This handle public API for UserScripts like Greasemonkey, browser's extension.
irodr dispatch "userscript-init"
event to window
object when irodr have been finished initialazation.
You have to listen the "userscript-init"
event before invoke window.userScript.*
API.
window.addEventListener("userscript-init", (event) => {
// Your userscript code is here
});
Return active content or undefined.
interface UserScriptActiveContent {
id: string;
author: string;
publishedDate: Date;
// if is not update, same with publishedDate
updatedDate: Date;
title: string;
body: string;
url: string;
}
Return active subscription or undefined.
interface UserScriptActiveSubscription {
title: string;
url: string;
iconUrl: string;
htmlUrl: string;
}
Register shortcut key.
Trigger exist shortcut key.
SubscriptionContent::componentDidMount
SubscriptionContent::componentDidUpdate
SubscriptionContent::componentWillUnmount
Subscript event
and register handler
that is called when the event
is dispatched.
window.addEventListener("userscript-init", (event) => {
userScript.event.subscribe("SubscriptionContent::componentDidMount", (content) => {
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", true);
}
});
});
See also other UserScript examples.