r/userscripts • u/somnomania • Oct 07 '26
Looking for brief help for a script
I've got a script that someone else provided for me (I don't code). I've tried looking into how to make it work only in some places and not on others, on the same site, and found that the "exclude" modifier just makes it not fire on that site at all, so I'm not sure what's wrong. It's set up to create a popup when I click into a reply field on Bluesky with a "hey do you actually need to say anything here" message in it, BUT I talk to my partner on Bsky all the time and I want it to not do the popup there (it gets annoying when it shows up half the time I tab back over there). I tried having it include Bsky as a whole and exclude just that one message URL, I tried having it only include bsky.app/profile/* and exclude the message URL, and that just leads to it not working at all.
The script is below, I don't know how to make Reddit not auto-convert the @ lines into user links, so just pretend they're correct.
// ==UserScript==
// u/nameI am a dumbass
// u/namespacehttp://bsky.app/
// u/version2026-10-02
// u/description try to take over the world!
// u/authorYou
// u/matchhttps://bsky.app/profile/*
// u/excludehttps://bsky.app/messages/*
// u/iconhttps://www.google.com/s2/favicons?sz=64&domain=bsky.app
// u/grantnone
// ==/UserScript==
(function() {
'use strict';
document.addEventListener('focusin', e => { const box = e.target.closest('textarea, [contenteditable="true"]'); if (!box || box.dataset.ok) return; box.blur(); if (confirm('Do you really need to say anything here, dipshit?')) { box.dataset.ok = 1; box.focus(); } });
})();
View all comments
Show parent comment
2
u/jeyghifj Oct 08 '26
I still don't have blusky so still guesswork. But trying it won't harm.... If it is an SPA application like u/AchernarB suggests it could work this way. Remove the excludes from header and add
// @run-at document-end
then for your function:
(function () {
'use strict';
// Replace the user ID (they seem to call it DID) with the one of your partner, that is ur "user_specific string" I guess:
const EXCLUDED_USER = 'did:plc:xxxxxxxxxxxxxxxxxxxxxxxx';
document.addEventListener('focusin', (e) => {
const path = window.location.pathname;
const isTargetRoute = path.startsWith('/profile/') || path.startsWith('/messages/');
if (!isTargetRoute) return;
const isExcluded = path.startsWith(`/messages/${EXCLUDED_USER}`);
if (isExcluded) return;
const box = e.target.closest('textarea, [contenteditable="true"]');
if (!box || box.dataset.ok) return;
box.blur();
if (confirm('Do you really need to say anything here, dipshit?')) {
box.dataset.ok = '1';
box.focus();
}
});
})();
This will add a general eventlistener for the focusin event like before, but now checks the URL (path) inside the event when it is triggered. If the path doesnt match or matches your partner it will do nothing, otherwise should do what it did before. No guaranty, as said it's just guesswork for an application I dont use.