diff --git a/index.html b/index.html new file mode 100644 index 0000000..d581bb9 --- /dev/null +++ b/index.html @@ -0,0 +1,66 @@ + + +
+ +
Remote Instance Actions is a userscript I've written to aid in Mastodon moderation.
+ +(That really is just "Mastodon", not "fediverse". Sorry, Misskey admins).
+ +It's as simple as the image at the top makes it look! Just highlight the URL of an instance you want to silence or suspend, and select the new context option. It does a little bit of simple sanitizing and validation to make sure you highlighted what you wanted to highlight. Then, it checks to see if the instance is already limited. Finally, it opens a new tab to your instance's "New Domain Block" form.
+ +A userscript is sort of like a browser extension, but smaller! Just a little bit of Javascript code that gets run on certain pages to enhance the experience.
+ +If you're asking this question, you should probably know that you do actually need a browser extension to run userscripts. The most popular and feature-complete one by far (as well as the one this userscript was tested with!) is Tampermonkey.
+ +Tampermonkey Home Page Chrome Extension Firefox Add-On
At time of writing, the script doesn't work in Firefox and I haven't the foggiest idea why. Working on it.
+ +When writing a userscript, you have to hardcode in the URL of websites it will work on. That's fine for, say, Twitter, where it's always found at "twitter.com" (for the time being, anyway). Mastodon instances are a lot harder to write for. If I wrote it to, for example, check if the current page is a Mastodon instance and conditionally add the context menu item, it would have to run on every page you visit to make that check.
+ +The usual way to solve this problem is to just tell the user to modify the userscript to add the pages you'd like it to run on. That sucks for a number of reasons. The most obvious are that users don't want to have to go in and mess with the code, and that it breaks with Tampermonkey's update functionality. This page here is my overengineered solution.
+ +The userscript itself, in a usable state, isn't exactly stored anywhere on my server. There is a version that's very similar, but with a little bit of PHP where you would expect the @match directives to be. That PHP code fills in the match directives with domains provided via GET parameters before sending it to your browser. Since the script was installed from a URL with those parameters in it, Tampermonkey will include those same parameters when checking for updates.
+ +The slightly less technical answer is that using this install page generates the userscript with the proper domains set on the fly, and does so in a way such that Tampermonkey will fetch updates that are generated with the same domains.
Well, your browser will show you the code before installing, but if you want to inspect it beforehand it's available on my gitea instance. + +
If you're on the fediverse, I can be found at @monorail@glaceon.social.
+ +If you aren't... How exactly did you get here?
+ + + diff --git a/install_form.js b/install_form.js new file mode 100644 index 0000000..c45e5f4 --- /dev/null +++ b/install_form.js @@ -0,0 +1,22 @@ +// Convert each line of the textarea to a unique input element, so they're all passed with separate GET parameters +function updateForm() { + form = document.getElementById("install-form"); + instances = document.getElementById("instance-input").value.split("\n"); + + for (const instance of instances) { + let input = document.createElement("input"); + input.type = "hidden"; + input.name = "instances[]"; + input.value = instance; + form.appendChild(input); + } +} + +function faqHighlight() { + document.getElementById("whyform").style.backgroundColor = "#ffffee"; +} + +document.addEventListener("DOMContentLoaded", function() { + document.getElementById("install-button").addEventListener("click", updateForm); + document.getElementById("whyformlink").addEventListener("click", faqHighlight); +}); diff --git a/ria.png b/ria.png new file mode 100644 index 0000000..6445d8c Binary files /dev/null and b/ria.png differ diff --git a/style.css b/style.css new file mode 100644 index 0000000..35c864d --- /dev/null +++ b/style.css @@ -0,0 +1,62 @@ +body { + width: inherit; + margin: 0 22.5%; + font-family: Sans-Serif; + background-color: #D0D0D0; + font-size: 14pt; + color: #111111; +} + +/* +@media screen and (max-width: 900px) { + body { + width: 90%; + } +} +*/ + +footer { + padding: 0 4em; + font-size: 10pt; + text-align: center; +} + +form { + text-align: center; +} + +figure { + margin: 1em auto 0 auto; + text-align: center; + font-size: 12pt; + font-style: italic; +} + +figcaption { + margin: 0.5em; +} + +img { + display: block; + margin-left: auto; + margin-right: auto; +} + +h1, h2, h5 { + text-align: center; + margin-bottom: 0; +} + +h5 { + margin-top: 0; +} + +textarea { + width: 40%; + height: 5em; +} + +input[type=submit] { + width: 10em; + height: 4em; +}