/r/userscripts
A place for discussion of all things related to userscripts.
A place for discussion of all things related to userscripts.
RELATED:
/r/userscripts
Is it possible to create a userscript to automatically always display the live word count? I was able to use css to force the word count bubble to always appear but I can't get it to show the text with the actual number of words. It seems like the specific element only appears after some script is run when you manually click the checkbox and ok button on the menu screen. I'm not sure if it's possible to even automate this... I've searched for various extensions online and haven't been able to find a solution yet.
I found a userscript on greasyfork that I am trying to change to function on the Amazon Video website. The script was originally for Netflix and I just changed the class name of the subtitles and it worked for Hulu's site, but for some reason I can't get it figured out for Amazon's site. I've tried various different class names, but none seem to work. I'm pretty positive this is the correct element to target. Does anyone have any ideas on why it's not working?
// ==UserScript==
// @name Amazon subtitle cleanup
// @namespace Violentmonkey Scripts
// @match https://www.amazon.com/*
// @grant none
// @version 1.0
// @description Remove all "[inhales]", "[loud noise]" from the subtitles
// @icon https://upload.wikimedia.org/wikipedia/commons/4/4a/Amazon_icon.svg
// ==/UserScript==
let observed_node = undefined
let kill_song_lyrics = true
const cleanup = (t) => {
if (kill_song_lyrics && t.includes('♪')) {
return '' // ignore song lyrics
} else if (t.includes('[') && t.includes(']')) {
return t.replace(/(- *)?\[[^\]]+\]/g, '') // (maybe "- ") "[" .. (not "]")+ .. "]"
} else if (t.includes('(') && t.includes(')')) {
return t.replace(/(- *)?\([^\)]+\)/g, '') // (maybe "- ") "(" .. (not ")")+ .. ")"
}
return t
}
const on_mutated = (changes) => {
const ts = observed_node.querySelectorAll('atvwebplayersdk-captions-text')
for (let i = 0; i < ts.length; i++) {
const t = ts[i].innerHTML
const nt = cleanup(t)
if (nt !== t) {
ts[i].innerHTML = nt
// console.log({ original: t, filtered: nt })
}
}
}
const observer = new MutationObserver(on_mutated)
const reobserve = () => {
const elems = document.getElementsByClassName('atvwebplayersdk-captions-text')
if (elems[0] !== undefined) {
if (observed_node !== elems[0]) {
observed_node = elems[0]
console.log({ observed_node })
observer.observe(observed_node, { childList: true, subtree: true})
}
}
window.setTimeout(reobserve, 100)
}
const run_tests = () => {
// the tests are lightning fast, so just do run them quickly on every script startup
const test_cleanup = (source, expected) => {
console.assert(cleanup(source) === expected, { test_result: false, source, expected, actual: cleanup(source) })
}
test_cleanup('normal text', 'normal text')
test_cleanup('[coughs]', '')
test_cleanup('[coughs] yeah', ' yeah')
test_cleanup('-[coughs]', '')
test_cleanup('- [coughs]', '')
test_cleanup('- (inhales)', '')
test_cleanup('some ♪ singing', '')
console.log('tests ok')
}
console.log('Netflix subtitle filter userscript starting up')
run_tests()
reobserve()
I use Google keep a lot but their extension don't work anymore . So can anyone create a bookmarklet/script for me so when a user highlight a text on a webpage and click the button on bookmarklet or script . It will save the highlighted text with their respective webpage URL to google keep. I dunno coding, i asked chat gpt but all in vain
P.S. Google keep- (keep.google.com), (note.new)
So I'm trying to create a function in my userscript and make it available to be called on the dev console in Firefox. While attempting to do so on github, I was running into issues with this and since I have done it tons of times in the past on other sites, I had assumed I had mucked something up in my script. But even boiling it down to really basic snippets, I still can't get it to work. Any help?
// ==UserScript==
// @name reddit-test
// @namespace Violentmonkey.github-test
// @include /https:\/\/(old|new|www)?\.?reddit.com(\/r\/userscripts)?\/?$/
// @grant none
// @version 1.0
// @author -
// @description add function to page and make it callable from firefox dev console
// ==/UserScript==
let myfunc = function(selector) {
let elems = document.querySelectorAll(selector);
return elems;
}
window.myfunc = myfunc;
And then running that on reddit, I get the following in the dev console
myfunc('#header').length
1
Taking the same thing and making a new script for gitub (e.g. just name and include are changed)
// ==UserScript==
// @name github-test
// @namespace Violentmonkey.github-test
// @include /https:\/\/github.com\/?$/
// @grant none
// @version 1.0
// @author -
// @description add function to page and make it callable from firefox dev console
// ==/UserScript==
let myfunc = function(selector) {
let elems = document.querySelectorAll(selector);
return elems;
}
window.myfunc = myfunc;
Then running on github homepage, I get the following in dev console (note: script appears on Violent Monkey icon console.log
so the @include
is ok and console.log
statements show up and functions seem to work within the context of the userscript so I can do things like grab element text / update document title / etc but it appears to be blocked from adding the function to the window / showing up in the dev console for some unknown reason).
myfunc('.AppHeader').length
Uncaught ReferenceError: myfunc is not defined
<anonymous> debugger eval code:1
I notice that the dev console on github has a a lot of errors about Content-Security-Policy
and similar even when Violent Monkey is completely disabled. However, I am still able to manually create functions under the window object from dev console (e.g.):
>> window.myfunc = function() { console.log('success'); };
function myfunc()
>> myfunc()
success
I would normally assume that this is something related CORS / cross-site scripting but would that even apply for userscripts that are simply operating on the page without loading things from other domains (e.g. not importing libraries from a cdn like jQuery / etc but just plain vanilla JS, entirely self-contained in the userscript)?
I've been searching for about an hour already and I am as stumped as when I started. I used to be moderately ok with javascript once upon a time but haven't kept up with things over the last 5 or so years. Hoping someone who is more current than me can help shed some light and offer advice on how on to make my userscript functions available via the dev console.
edit: obviously, the function above is just a simple example that I am using for testing. The final function that I plan to add will be significantly more complex but want to stomp out this issue before I continue.
edit 2: even stranger, I just retested the github userscript under chromium + VM and it actually works as expected over there (no modification). So I guess I need to test if this is a) due to some other setting/addon, b) some issue with github not liking FF, b) some VM+FF specific bug or limitation... I guess at least I'm not going crazy but would have been nice if it "just worked".
Is it possible to do a script to redirect Gyazo images directly to file? I'm currently using Redirector to do it, but it doesn't work if the image is jpg or webp, also I have to press f5 for the redirection to work.
I want to write a script that scans links in a page and sends some of them to a url. I can do this myself but I have two questions:
The url will always be foreign to the current url, so, are there cors restrictions for http requests, or can I make http requests to arbitrary urls? Should I use xhr or fetch?
I need to send all links exactly once so I need to store the ones I've sent already. This must survive across browser restarts. Is there some storage, preferably k/v like localstorage that is shared among all websites?
Thanks
Could someone help me with a simple request? I need to add some parameters to the end of an URL, preferably before the page reloads.
Original URL: https://solvnetplus.synopsys.com/s/global-search/%40uri#q=hello%20world&t=All&sort=relevancy
Hi!
Can someone help me create a script that automatically expands "Show more" in the youtube sideba. I found this script but it no longer works. I tried to edit it but unfortunately I'm not good at javascript
YouTube - automatically expand subscription list
Thanks in advance for reading.
Recently Artstation has made a bizarre change in making a once persistent icon that shows if a gallery has multiple images to one that shows up on mouse hover.
Example gallery https://www.artstation.com/felixriano
Before Hover
After Hover (note the image preview hover is a extension)
It appears that simply changing a style from display: none to display: block lets the icon appear. But it has been many years since I've worked on this stuff and I am unsure how to apply this.
Example - Display: block;
I am not sure how to target the entire gallery in a way that the icon is persistent despite any new instances of the mouse hovering over a thumbnail. As with just changing the display from none to block is only temporary till you hover over the thumbnail.
This script assigns a unique background color to each username based on their name. Makes it easier to differentiate users on the page (only works in old.reddit)
// ==UserScript==
// @name Random Colors for Users On Reddit
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://old.reddit.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=reddit.com
// @grant none
// ==/UserScript==
let authorColors = new Map();
function Main() {
let _authors = document.getElementsByClassName('author');
for (let i = 0; i < _authors.length; i++) {
let authorName = _authors[i].innerText;
if (!authorColors.has(authorName)) {
let color = stringToColour(authorName);
authorColors.set(authorName, color);
_authors[i].style.color = color;
} else {
_authors[i].style.color = authorColors.get(authorName);
}
}
setTimeout(Main, 500);
}
function stringToColour(str) {
let hash = 0;
for (let i = 0; i < str.length; i++) {
hash = str.charCodeAt(i) + ((hash << 5) - hash);
}
let colour = '#';
for (let i = 0; i < 3; i++) {
let value = (hash >> (i * 8)) & 0xFF;
colour += ('00' + value.toString(16)).substr(-2);
}
return colour;
}
Main();
I recently found this userscript that adds a speed playback to yt music, I love it, however I have two problems, I would like to disable the pitch correction when changing the speed, I tried this but it didn't work.
(function() {
'use strict';
const originalPlaybackRate = HTMLMediaElement.prototype.playbackRate;
Object.defineProperty(HTMLMediaElement.prototype, 'playbackRate', {
set(value) {
// Set the playback rate without pitch correction
this.defaultPlaybackRate = value;
this.playbackRate = value;
},
get() {
return originalPlaybackRate.get.call(this);
}
});
})();
The second thing is that when I click to change the speed it also clicks on the player and it closes and I don't know how to fix it.
I prefer to view/read Reddit via new.reddit.com
interface, but do all the moderation stuff from reddit.com
(aka sh.reddit.com
) version. This includes the mod queue, which I open by clicking the little shield icon and selecting 'Mod Queue' there. It opens https:///new.reddit.com/r/mod/about/modqueue and I want to use https://www.reddit.com/mod/queue, so I wrote this very basic script:
// ==UserScript==
// @name Always New ModQueue
// @namespace 9bf36c681d35d52913b3bda74ddf6127318ed7b0
// @version 0.1
// @description Forces opening mod queue in sh.reddit
// @author /u/eftepede
// @match *://new.reddit.com/r/mod/about/modqueue
// @grant none
// @run-at document-start
// ==/UserScript==
(function () {
'use strict';
top.location.replace("https://www.reddit.com/mod/queue");
})();
Unfortunately, it doesn't work when I click the icon (or even right-click it and try opening in a new tab). I always get the new.reddit...
page, but when I refresh it via standard Ctrl+r, the redirection works.
What am I doing wrong?
Hi!
I'm aware that there's subreddits that allow users to upload pictures in a post directly. However, this feature seems to be restricted to the new/beta Reddit design though, which I don't really like. It's a lot more wasteful in terms of how much meaningful content is packed at any given time on screen.
So yeah, I figured I'd check over here and see if anyone could make a userscript that allows something like drag-and-dropping an image into the comment box on Old Reddit to post images directly, to avoid constantly having to go back and forth between the new and the old Reddit designs.
Thanks in advance for reading.
An unofficial script collection created using the cobalt.tools API.
Currently available scripts:
When using Google Sheets on MacOS with a Scandinavian keyboard layout, it unfortunately hijacks several keyboard combinations required to type in crucial characters, such as $, { and }.
I made this workaround to allow typing in the missing characters and have been using it a while with great effect.
The workaround may work for other country-specific keyboard layouts. It’s been very thoroughly been tested with the Danish keyboard.
Note: Google Sheets use these keys for range selecting etc. and those functions are not remapped to other keyboard combinations. Not a loss at all, IMHO.
https://gist.github.com/f-steff/ace84434e1ee4e1107bcf0ba8d72ed2b
ok, i'm pretty sure that you guys are going to pile on and eviscerate me for asking this, but I've got a number of userscripts running for youtube - normally everything is fine/great. All of a sudden (translation: no idea why; didn't change anything) it is playing 5 seconds of each track and skipping to the next one in the queue or playlist - whichever you're in! SO unbelievably frustrating. I've tried disabling all the scripts and turning them on one at a time, but as soon as I get the two functions i require (working ad skip+local download) - here comes the bullshit skipping. I'm in Edge. Also tried turning on dev tools, hoping I could figure out how to get it to stack trace in realtime, but honestly, I don't know how to use this very well. All my debugging/QA experience is multi decades old. I'm hoping that after I wade through the 35 oblgatory assholes calling me every kind of stupid for asking the question, some kind person will have perhaps heard of this behavior and tell me how to get it to stop. Thanks!
Spotify Enhancer is a set of userscripts that enhance the Spotify Web Player.
Currently available scripts:
I'm using voilent monkey in kiwi browser (android), i want to bypass NSFW links but when i use bypasser script it bypasses but redirects to a scam video page and not the actual content is there and script that works as good as bypass.city??
YouTube Enhancer is a set of userscripts that enhance your YouTube experience.
Currently available scripts:
Hi all, brand new to Userscripts and terrible at code.
I am trying to find a way to highlight specific words or characters on an HTML/CSS/JS page in Safari. Has to be Safari due to company requirements.
A good example of what I want to do it like the find command. I found Multi Find for other browsers and that’s almost perfect but doesn’t work in Safari
I’m trying to highlight things like “.co” “app.” Or “+44” these are often mid line so only wanting to highlight parts of elements.
Unfortunately I can’t upload an example of the page for privacy reasons, but would really appreciate and guidance, dumbed way down if possible.
Is Userscripts the right tool to even be looking at?
I've recently been directing the development of TeXSend, which is intended to eventually be a suite of userscripts for adding LaTeX compiling to popular email services. Right now, TeXSend-Gmail is in a good place, and I'd like to port this over to work with Outlook.
The programmer who I've relied on for the majority of the coding for TeXSend-Gmail has some other responsibilities that they need to attend to for a while, and so will be unavailable to continue working on this. I'm hoping to find someone who is able to work on this port. I'm able to do testing and minor JS adjustments, but I'm far from a skilled JS programmer myself.
I need to clarify, this is non-profit work being distributed under an MIT license. As such, I cannot offer any compensation other than credit as a contributor. This is a suite that will hopefully prove beneficial to many people in STEM (academia in particular), and I hope that alone is sufficient encouragement for someone to volunteer.
Thank you.
Note: Title should have said "TeXSend". "TeXMail" was a working title.
This user script adds a floating panel to Google Maps place pages, allowing you to scrape and export reviews easily.
URL: https://greasyfork.org/en/scripts/510952-google-maps-reviews-scraper-exporter
Google Maps Reviews Scraper & Exporter in Action
For each review, the script collects:
Enjoy more accessible access to Google Maps review data with this handy user script!
I have a very specific use case for a tampermonkey userscript. I need an inactive tab on my firefox browser to get a looping key presses and mouse clicks at a specific coordinate while I browse the net on another tab. Is this possible?
Obviously, this is for some idle game that I am running in a background tab while I do something else. Idle Wizard on kongregate is what I'm playing.
More specifically, the parameters I need are something like this.
Every 5 seconds:
Loop this indefinitely until i disable it.
I tried to do it on AHK which has a simplified code that a random dude like me can understand, but I'm finding that AHK cannot really distinguish a specific firefox tab that is running in the background. As for userscript code system, it's way too complicated for me to understand without any programming knowledge.
Edit: Solved! See comments.
function addShortcuts() {
const keyHandler = (e) => {
if (e.shiftKey && e.code === 'KeyL') {
toggleLatex()
} else if (e.shiftKey && e.code === 'Slash') {
waitForElement('body > div.wa:not(.aou) > div[role=alert]', 5).then(d => {
const xpath = '//tr[th/text()="Formatting"]/following-sibling::tr';
const row = document.evaluate(xpath, d, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
const html = '<td class="wg Dn"><span class="wh">Shift</span> <span class="wb">+</span> <span class="wh">L</span> :</td><td class="we Dn">Toggle LaTeX</td>';
row.innerHTML = html;
});
}
}
window.addEventListener('keypress', keyHandler);
}
I can make this "shift + [alphanumeric]", but nothing else actually works.
I'd particularly like like do "ctrl+alt+L".
The userscript in question: https://github.com/LoganJFisher/LaTeX-for-Gmail
If you want the buttons to look prettier you can edit the add_button
function
Edit: This has gradually evolved into this project: https://github.com/LoganJFisher/LaTeX-for-Gmail?tab=readme-ov-file
I'm looking to find a way to add LaTeX equation rendering to Gmail in Firefox. Could someone create such a userscript please?
I've tried searching for Gmail add-ons, Firefox extensions, and userscripts (using Greasemonkey and ViolentMonkey). I even tried editing the MathJax for Reddit userscript by changing its @match URL to https://mail.google.com/*, but that didn't work (the script triggers, but doesn't solve the issue).
I just need a solution that can handle equations. I don't need it to be capable of rendering whole documents right in Gmail. I need it to be for Firefox though, not Chrome.
Example: If you look at the sidebar of /r/askphysics, you'll see this. If you install the userscript "MathJax for Reddit" that they recommend, you'll then instead see this. I want the same thing for sent and received emails viewed on https://mail.Google.com
I'm getting desperate and frustrated that my attempts keep failing ad I don't understand why.
Replace the YouTube logo with a custom logo styled to resemble the original logo but with the text “FuckYou” or "Fuck YouTube".
Fuck YouTube - https://greasyfork.org/en/scripts/508890-youtube-logo
FuckYou - https://greasyfork.org/en/scripts/508696-you-logo-on-youtube
Tried making my first user script (i had few for personal use before), let me know if I made any mistakes or if this kind of scripts even allowed or not lol.
https://greasyfork.org/en/scripts/451541-instagram-video-controls no longer works or FOSS extension