zarjay / Mint Utils


Version: 1.0.2+436ab43 updated

Summary: Library of functions runnable from the browser console.

License: MIT;

JR's Utils

Set of functions runnable in the browser console (e.g., Chrome DevTools) for playing around with webpages.



Injects CSS onto the page.

jr.css(' { display: none; }');


Makes the page editable. Set canEdit to false to make it non-editable.

jr.edit(); // page is now editable
jr.edit(false); // revert back


Returns a count of how often values appear from the specified values.

jr.frequency('apple', 'apple', 'orange', 'banana', 'orange', 'grapefruit')
// returns {apple: 2, orange: 2, banana: 1, grapefruit: 1}

const numbers = [4, 7, 7, 3, 4, 8];
// returns {3: 1, 4: 2, 7: 2, 8: 1}

jr.html(content[, position])

Appends HTML onto the body of the page. You can specify a position of afterbegin to prepend it onto the body. (This method uses insertAdjacentHTML internally.)

jr.html('<div style="color: green">Hello</div>', 'afterbegin');


jr.include(asset[, type])

Includes a CSS or JS file onto the page.

If asset is a URL, the file will be included directly. The file's extension (.css or .js) is used to determine what type of file it is. Otherwise, pass in css or js as the second parameter.

If asset is not a name, the script will search and use the first JS file that matches.

A promise is returned that resolves when the file has finished loading.


jr.include('').then(() => console.log($('body').text()));

jr.include('', 'js');

jr.include('moment').then(() => console.log(moment().format()));

// Instead of using the promise, you can include it and use the library
// directly after that. Unless the web server hosting your library is
// extremely slow, the file should be loaded by the time you enter
// your next command.


Block annoying event listeners on the page with a capture event listener. Here are some examples where this method is useful:

// Many quotation and lyric websites hijack the copy event and inject
// extra text into whatever you copy. Use `intercept` on the whole page
// to prevent that from happening.

// Some websites prevent right-clicking on images. Use `intercept` to
// prevent right-click from being blocked.
jr.intercept(); // or jr.intercept('img');

// Some websites prevent text from being pasted into forms
// (text fields, password fields, etc.). Use `intercept` to prevent
// your paste from being blocked.

jr.js(content[, isImmediate])

Injects JS onto the page. You can already add JS in the browser console, so this isn't very useful unless you have some text you want evaluated into JavaScript the page and you don't want to use eval().



Returns the average of values.

jr.mean(90, 95, 98, 97, 94); // returns 94.8

const numbers = [4, 7, 7, 3, 4, 8];
jr.mean(...numbers); // returns 5.5


Returns the median of values.

jr.median(90, 95, 98, 97, 94); // returns 95

const numbers = [1, 2, 3, 4, 5, 6, 8, 9];
jr.median(...numbers); // returns 4.5


Returns the mode of values. An array is always returned, since a set of values can have multiple modes.

jr.mode(1, 3, 6, 6, 6, 6, 7, 7, 12, 12, 17); // returns [6]

const numbers = [1, 1, 2, 4, 4];
jr.mode(...numbers); // returns [1, 4]

jr.mode(1, 2, 3); // return [], since there is no mode


Pauses all video and audio elements on the page. Use target to specify what to pause.

jr.pause(); // pause everything

jr.pause('video'); // only pause videos

jr.pause('.ads'); // pause specific elements[target])

Plays the first video or audio element found on a page. Use target to specify what to play.; // play the first <video> or <audio> found'#video-247'); // play specific element


Works kinda like jQuery's $(), but uses querySelectorAll() under the hood (and returns a true array, not a NodeList). Returns an array of DOM elements.

If target is a string selector, querySelectorAll is called and turned into an array.
If target is a Node element or NodeList or HTMLCollection, the input is transformed into an array of elements and returned.

// Everything returns an array
jr.query(document.querySelectorAll('div, span'));


Returns the sum of values.

jr.sum(90, 95, 98, 97, 94); // returns 474

const numbers = [4, 7, 7, 3, 4, 8];
jr.sum(...numbers); // returns 33


Returns an array with duplicate values removed.

jr.unique(1, 1, 2, 1, 7, 4, 4, 3); // returns [1, 2, 7, 4, 3]

const numbers = [4, 7, 7, 3, 4, 8];
jr.unique(...numbers); // [4, 7, 3, 8]

Rating: 0