Native javascript equivalent of jQuery :contains() selector

This should do in modern browsers: function contains(selector, text) { var elements = document.querySelectorAll(selector); return [].filter.call(elements, function(element){ return RegExp(text).test(element.textContent); }); } Then use it like so: contains(‘p’, ‘world’); // find “p” that contain “world” contains(‘p’, /^world/); // find “p” that start with “world” contains(‘p’, /world$/i); // find “p” that end with “world”, case-insensitive …

Apply a Greasemonkey/Tampermonkey userscript to an iframe

In Greasemonkey (And Tampermonkey and most userscript engines) a script will fire on an iframe automatically if it meets the @include, @exclude, and/or @match directives. And, a popular question is how to stop Greasemonkey from firing on iframes. So, if your script had a match like: @match https://fiddle.jshell.net/* It would fire on jsFiddle “output” pages … Read more

How can I load a shared web worker with a user-script?

You can use fetch(), response.blob() to create an Blob URL of type application/javascript from returned Blob; set SharedWorker() parameter to Blob URL created by URL.createObjectURL(); utilize window.open(), load event of newly opened window to define same SharedWorker previously defined at original window, attach message event to original SharedWorker at newly opened windows. javascript was tried … Read more

UserScripts & Greasemonkey: calling a website’s JavaScript functions

Background Doesn’t Greasemonkey inject my extensions JavaScript already? Can someone clarify this for me please. Greasemonkey executes your scripts in a sandbox, which is a restricted environment without direct access to the JavaScript in the page. Earlier versions of Greasemonkey injected scripts directly into the page, but this introduced serious security vulnerabilities. In the old … Read more

Where are Chrome/Tampermonkey userscripts stored on the filesystem? [closed]

Tampermonkey scripts are super easy to update via the Tampermonkey tab. See the Tampermonkey FAQ, or just try it. Tampermonkey scripts were stored in a special SQLite database and were/are not directly editable in file form. Update: As of version 3.5.3630, Tampermonkey scripts are now stored using Chrome’s extension storage. They are still not editable … Read more

Injecting JS functions into the page from a Greasemonkey script on Chrome

The only way to communicate with the code running on the page in Chrome is through the DOM, so you’ll have to use a hack like inserting a <script> tag with your code. Note that this may prove buggy if your script needs to run before everything else on the page. EDIT: Here’s how the … Read more

Why is usage of the downloadURL & updateURL keys called unusual and how do they work?

Use of those keys is discouraged mainly by Greasemonkey’s lead developer. Most others, including the Tampermonkey team feel no need for such a warning. Also note that those directives are not always required for auto-updates to work. Some reasons why he would say that it was unusual and that “most” scripts should omit it: In … Read more

Greasemonkey/ Tampermonkey @match for a page with parameters

@match only works on the protocol/scheme, host, and pathname of a URL. To trigger off the query parameters, you can either use @include or use @match and also test the URL yourself. Note that the @match approach performs faster. With @include, you can use a regex syntax. See, also Include and exclude rules. In this … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)