User Scripts
Jancy comes with built-in support for user scripts and provides it’s own API for you to build user scripts with.
If you have existing Greasemonky/Tampermonkey user scripts, Jancy supports a small subset of the Greasemonkey/Tampermonkey APIs.
Metadata Block Fields
These are the currently supported metablock fields and how they’re interpreted.
@namedisplayed in the user script manager@versiondisplayed in the user script manager@includeworks like GreaseMonkey/TamperMonkey@matchworks like GreaseMonkey/TamperMonkey@requireworks like GreaseMonkey/TamperMonkey@connectworks like GreaseMonkey/TamperMonkey@run-atworks somewhat like GreaseMonkey/TamperMonkey. We only supportdocument-startanddocument-endand the default isdocument-end.
All other metablock fields are ignored.
// ==UserScript== // @name Bigger Ticketmaster Dots // @version 1 // @description Makes the dots on the Ticketmaster seatmap bigger. // @author Joshua May // @match https://*ticketmaster.com/*/event/* // @match https://*ticketmaster.ca/*/event/* // @match https://*ticketmaster.com/event/* // @match https://*ticketmaster.ca/event/* // @match https://*livenation.com/event/* // @match https://*livenation.com/*/event/* // ==/UserScript==
JancyAPI Object
Jancy adds a jancyAPI object to the window object of every page and frame it loads.
window.jancyAPI.addStyle(style)
style(string) - CSS you want to add to the current page.
window.jancyAPI.consoleLog(message)
message(string)
Writes message to the Jancy console.
window.jancyAPI.clipboard.writeText(text)
text(string)
Writes text to the clipboard
window.jancyAPI.clipboard.writeTextWithNotification(text)
text(string)
Writes text to the clipboard and generates an OS notification.
window.jancyAPI.dispatchAction(action, args)
Document me.
window.jancyAPI.executeCode(code)
code(string)
Returns a promise that resolves with the result of executing code in the webpage.
window.jancyAPI.getPath(name)
name(string)
Returns a promise that resolves with a string that corresponds to name. The following are the valid values for name:
homeUser’s home directory.tempTemporary directory.exeThe current executable file.moduleThe libchromiumcontent library.desktopThe current user’s Desktop directory.documentsDirectory for a user’s “My Documents”.downloadsDirectory for a user’s downloads.musicDirectory for a user’s music.picturesDirectory for a user’s pictures.videosDirectory for a user’s videos.recentDirectory for the user’s recent files (Windows only).logsDirectory for your app’s log folder.crashDumpsDirectory where crash dumps are stored.
window.jancyAPI.getTabInfo()
Returns an object with the following properties.
tabId(string) a unique identifier for the tab the user script is running in
window.jancyAPI.getProfileInfo()
Returns a promise that resolves with a profile object or null if a profile isn’t selected into the tab.
window.jancyAPI.readFromMemory(tag)
tag(string)
Returns a promise that resolves with the data previously associated with tag or null.
window.jancyAPI.scrollToBottom()
Scroll the current page to the bottom.
Mileage may vary depending on the page.
window.jancyAPI.scrollToTop()
Scroll the current page to the top.
window.jancyAPI.writeToFile(path, text)
path(string)text(text)
Appends text to the file at path.
window.jancyAPI.writeToMemory(tag, data)
tag(string)data(any)
Associates data with tag and can later be retrieved with jancyAPI.readFromMemory().
data must be a standard Javascript type.
window.jancyAPI.xmlHttpRequest()
Document me.
An Example
The following is an example user script that makes the non-resale dots on a Ticketmaster seat map bigger.
- Copy the following example to a new file called
bigger-tm-dots.js.- Add
bigger-tm-dots.jsto Jancy via the User Script settings panel (File -> Settings -> User Scripts)
// ==UserScript== // @name Bigger Ticketmaster Dots // @version 1 // @description Makes the dots on the Ticketmaster seatmap bigger. // @author Joshua May // @match https://*ticketmaster.com/*/event/* // @match https://*ticketmaster.ca/*/event/* // @match https://*ticketmaster.com/event/* // @match https://*ticketmaster.ca/event/* // @match https://*livenation.com/event/* // @match https://*livenation.com/*/event/* // ==/UserScript== const radius = 16 // change this to be your desired dot size /* This is the CSS we're injecting into the page. */ const style = ` circle[data-component="svg__seat"].is-available { r: ${ radius }; } ` /* For most ordinary websites, we could just call window.jancyAPI.addStyle() or ** GM_addStyle() (for GreaseMonkey you need to add @grant to the Metadata block) ** and be done with it but for TM we need our custom CSS to be injected ** into the page. The following bit of code creates a style element, set some properties ** along with the innerHTML and then adds it as a child element to the head node of the ** of the page. */ let stylesheet = document.createElement('style') stylesheet.rel = "stylesheet" stylesheet.type = "text/css" stylesheet.innerHTML = style document.head.appendChild(stylesheet)