Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Release] Fixes and Improvements (userscript)

September 11 (6 years ago)

Edited October 01 (6 years ago)

(Pretty new here so I don't know if this belongs in this category or even is allowed on the forums but I figured it was worth a shot if I can help some people out. If the thread gets deleted I won't bring it up again. This is posted with no ill-will towards anyone at Roll20. )

Roll20 Fixes and Improvements

or: How I Learned to Stop Worrying and Love the Bomb

I made a thing. It fixes things. It adds things to roll20 that I needed in my game yesterday so I added them yesterday.
It's possible these things will be useful to someone else out there and so I'm putting them in the wild. Be gentle; I make weird functions.
Anyways, the fixes!

  • Displays tokenname on select
    • When a token is clicked on, shows its name if you have permission to see it. When deselected, hides it again. Won’t hide it if it was shown to begin with.
    • (Mouse position is strangely recorded incorrectly in this gif. On click shows, off click hides)
       
  • Allow Macros to be hidden
    • Adds a button to the edge of the macrobar that lets you move the darn thing off the screen. Really useful if your screen is tiny.
       
  • Create a button to toggle fullscreen
    • Mobile device users would probably get the most out of this one.
       
  • Fix Pings
    • sendPing (API) didn’t move player's views to the location specified. Or care if you were on the same page as the ping. Both of those are fixed.
    • Additionally, if you specify a playerid in sendPing, only that player will be moved and the circle won't appear on their page. Great for camera accounts or points of interest.
    • Alternative configuration: sendPing can be set to "2" in the configuration menu, this will change the behavior of the fix in the following ways
      • Global pings will be delayed by 1 second
      • ALL players not running the script will receive pings.
      • Player and page will only be respected if they're also running the script and have it set to "2"
  • CSS Tweaks (Mostly tablet focused. Disabled by default)
    • Remove player names/ avatars from macrobar region
    • Remove the zoom slider (magnifier is more reliable)
    • Remove sidebar show/hide button (why not?)
    • Increase chat button sizes (for fat fingers)
    • Permanently hide turn order (Combat is on a big screen already)
  • Customize token actions
    • Set gmnotes to “blank” on a token to hide Macros for that token. If the token is a character, abilities will still show up. You can use this to have two different tokens have two different token action menus. Be careful about filling up your game with a ton of pseudo-characters though, you’ll probably start lagging.
  • Pathfinder Community Sheet Custom Attribute Name Fix
    • Buffs on the community sheet didn’t display the custom name of the custom attribute.
       
  • Token Names Auto-split onto newlines
    • Get hype. Splits the name by spaces, combines them into chunks that aren’t bigger than the width of the token. 
    • \n forces new line, _ forces a space that won't go to a new line.
    • This also fixes a bug in roll20 where token names are drawn twice if not a GM and advanced fog of war has been enabled before for a page. To use the bug fix without any auto-splitting, just set this option to "1".
  • Toolbar Quick Button
    • Put a bunch of abilities/ macros into a toolbar button. All are pulled from a macro named "ToolBar".
    • First line is the button icon. (emojis or pictos font characters supported)
    • Each line after that is of the format icon||displayName||command.
    • Command syntax should be the same as API command buttons.
    • Will pull the ToolBar template from individual player's macro list first, and if not found check the first visible macro to that player. 
  • Toggle settings as you'd like
    • Settings menu is in the help icon on the sidebar. Enter a number to turn a feature on/ off. They're less silly names than I'd normally choose and they correspond to the order on this page. They should save between restarts and updates.

Some things that may be useful (API only)

Sets all selected token’s gmnotes to ‘blank’

//Usage: !blankTokenActions
on("chat:message", function(msg) {
	if(msg.type == "api" && msg.content.indexOf('!blankTokenActions') == 0) {
		if (_.isUndefined(msg.selected)) {
			sendChat('Reality', '/w ' + msg.who + " You didn't select any token(s). How did you even get here?", null, {noarchive: true});
			return;
		}
		_.each(msg.selected, function(tok) {
			let token = getObj('graphic', tok._id);
			token.set('gmnotes', 'blank');
		});
	}
});

Deletes every attribute off a specified character sheet.

If you want to keep some attributes from being deleted, put ‘keep’ in the max value of it. Don’t open the sheet or they’ll all be regenerated again.

 //Usage: !flushAttr Exact Name of Character with no Quotes or anything like that around it
on("chat:message", function(msg) {
	if (msg.type == "api" && msg.content.indexOf('!flushAttr ') == 0) {
		msg.content = msg.content.replace('!flushAttr ', '');
		var charId = findObjs({_type: 'character', name: msg.content})[0].get('id');
		_.each(findObjs({_type: 'attribute', _characterid: charId}), ob => {if (ob.get('max') != 'keep') ob.remove()});
	}
});

Disclaimer: I don’t know what you’re doing, my scripts wouldn’t hurt a fly unless you tell them to. Use with caution.

The script is here.

Installation instructions are here.

I’ll post updates in this thread. Suggestions are welcome, requests are frowned upon.

Changelog:

V.0.3.3 (9/30/18)

  1. Fixed Toolbar quick button not showing up for players not specifically given permission to view it

V.0.3.2 (9/26/18)

  1. Fixed token actions not displaying if more than 1 token was selected while custom actions was enabled.

V.0.3.1 (9/23/18)

  1. Fixed token names being drawn twice (I'll submit a bug report to roll20 when I do more research)
  2. Toolbar quickbuttons can now contain javascript. just prepend your code with "j:" and it will run onclick.

V.0.3.0 (9/20/18)

  1. Added a quick macro button on the toolbar with customization. See above for setup details.

V.0.2.10 (9/19/18)

  1. Fixed text that isn't a token name from displaying correctly
  2. Fixed items disappearing/ jumping around (visually) when shift-selected

V.0.2.8 (9/17/18)

  1. Timeout and error checking for connections that don't load in time. Let me know if I need to increase this.

V.0.2.6 (9/15/18)

  1. fixPings can now be enabled globally. See bullet above for more info.
  2. fixPings now respect player if sent through API. sendPing (API) with a playerid of null will treat it as a global ping, otherwise it will respect the playerid and pageid sent through sendPing

V.0.2.2 (9/12/18)

  1. Added menu to save/ change preferences.
  2. Quicker render update on select
  3. Selected token now temporarily jumps to top while selected
  4. Fixed 'display token name on select' and 'customize token actions' not being mutually exclusive.
  5. All gmnotes are wrapped by <p> tags since Text Editor Update leaving Non-API GMs unable to use 'customize token actions'. A temporary/ permanent fix has been added.
  6. Multi-line token names now is a value instead of true/false indicating max number of lines.
    1. "\n" can be used to guarantee a line break
    2. "_ " can be used to insert space without risking it breaking
    3. Set splitTokName to 0 to never break (disable the feature completely)

V.0.1.2 (9/11/18)

  1. Initial Release

Known Bugs:

  1. Custom attributes don't always update on second time opening auto-popout character sheets
  2. Macrobar 'show/hide' button probably doesn't look good on multi-line macrobars
  3. Token actions are only hidden if "display token name on select" is also enabled
  4. Multiline token name draws twice sometimes
September 11 (6 years ago)
The Aaron
Pro
API Scripter

Neat!

September 11 (6 years ago)

Edited September 11 (6 years ago)
Mike W.
Pro
Sheet Author

I cannot wait to try some of these out.

  1. So your script does all of the above mentioned 'fixes'?
  2. Is there a way to toggle on\off some of these as options?


September 11 (6 years ago)

Edited September 12 (6 years ago)

Yeah, I use it as a bookmarklet primarily so i don't know greasemonkey calls yet but soonTM it will have a menu and be able to store preferences. Learned it. Should be live.
Here's how to install the script.

To install it just

  1. use Chrome/ Firefox, install Tampermonkey in the extension store.
  2. Visit the script install page linked above.
  3. Click Install, followed by Install

  4. Script is active. You're done. Options are in the ? mark on the left when you load up roll20

I can give a more involved tutorial but I'll probably implement a menu system in the next few days now that I don't have to worry about exceeding a character limit with bookmarklets. I implemented the menu. Old tutorial trimmed.

September 11 (6 years ago)

Edited September 11 (6 years ago)
vÍnce
Pro
Sheet Author

Can I send you the backlogged todo list for the pathfinder community sheet?  ;-P

Cool additions.  Thanks Justice

September 11 (6 years ago)

I have been eyeing the trello for a couple weeks so I'm going to put you down for a soft no. I just can't pick up another project. (Probably)
Suggestions are welcome in the meantime. I've just been adding things as they annoy me.

September 11 (6 years ago)
vÍnce
Pro
Sheet Author


Justice N. said:

I have been eyeing the trello for a couple weeks so I'm going to put you down for a soft no. I just can't pick up another project. (Probably)
Suggestions are welcome in the meantime. I've just been adding things as they annoy me.

I have a feeling your list may grow as well.  ;-P

Cheers


September 12 (6 years ago)

Edited September 12 (6 years ago)

Major update. I added a menu to swap settings without messing with anything. Updated the installation/ customization instructions according. Should be really easy for anyone to just grab and go. It will probably notify you that it needs extra permissions but they're just for storing your preferences. 

Also fixed some bugs and made it so that when selecting a token it jumps to the top of the zorder until you deselect it.
I'll probably make it a toggleable feature the next time I add toggles.

Also changed the way newline names behave. \n will force a new line, _ will create a non-breaking space. splitTokName now represents the max amount of lines shown. 0 defaults behavior back to original roll20.

September 12 (6 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Does the fix for the API ping require all participants to install the script, or just the GM?

September 12 (6 years ago)

From what I have test only the GM.

keithcurtis said:

Does the fix for the API ping require all participants to install the script, or just the GM?




September 12 (6 years ago)

Edited September 13 (6 years ago)

Fixes it on the receiver's end. All clients need it.
To correctly receive ping-jumps your client needs the fix installed. If you don't have it: no jump unless you're a GM.

I actually could probably write a hack to spoof the pings so only the GM has to install it...
I'll look into it tomorrow.

September 13 (6 years ago)

Edited September 13 (6 years ago)

HOLY MOLY

Justice N. said:

[Redacted]




September 13 (6 years ago)

Edited September 13 (6 years ago)

Please don't quote the entire OP. I'd like the information to stay relevant and concise and your quote will lose parity as soon as I update.

I was inspired to look into making it so only the GM has to have pings enabled and I've determined a few things.

  1. Yeah, move-pings from the API *can* be fixed as long as a GM in the game is running the userscript. It uses the GM as a passthrough so it is not ideal and I wouldn't recommend it unless I can iron out some bugs it may cause.
  2. No, pings respecting which page you're on *cannot* be fixed unless the client who wishes to be respected is running the userscript.

I think I'll make fixPings as a range of options.

0: Off and behaves like vanilla Roll20
1: On and API move-pings draw my focus if I'm on the correct page regardless of my GM status (default)
2: On and API move-pings draw my focus if I'm on the correct page. I'm a GM and I want players not running the script to move from API move-pings as well. Draw their focus as well, regardless of their page.

This has the downside of changing the default behavior to be more annoying for the end user however. Instead of doing nothing, players will jump regardless of their page. It will seem like a bug is introduced when it is actually just exposing a bug that was there all along. This isn't a problem if all your players are on the same page.

I could probably expand the API command while I'm at it and make it so you can target individual players, is that a useful thing to have?

September 13 (6 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

My first thought is that it would be a great boon for streamers, who often have a separate log in to record the video, so that it respects Fog of War and Dynamic Lighting and such. If it could be combined with something like the On My Turn script, so that each time the Turn tracker advances, the "camera" player window would be centered on the token whose turn it was, that would be a terrific boon.

So yeah, even if an API ping pull could target a player by name. that would be a plus.

September 15 (6 years ago)

There's a version with all that I just uploaded but it's a bit buggy and I'm out of dev time for the day so some other time.
Should work as described above (mostly).

Why is this so hard to write up in a way that isn't confusing as heck?

fixPings has 3 options now:

0. Ping fixes are off. Client behaves like vanilla. (sendPing API does not work unless player is GM)

1. Ping fixes are on. Client receives all pings as normal. If the ping’s page doesn’t match or the ping is a API ping and the player doesn’t match, it will be ignored.

2. Ping fixes are on. GM is additionally broadcasting out global pings to all players at a delay of 1 second. Non-GMs with fixPings set to “2” will be able to receive global pings, player specific pings, and page respected pings as normal with a 1 second delay. (Less than ideal. Coerce players into installing the script. I can even put up a version that just has the first feature and nothing more.)

September 16 (6 years ago)

I have installed the script via Tampermonkey and it seems like its on, but I'm not seeing any options appearing in the ? settings on the left. Is there something else i need to be doing?

September 20 (6 years ago)

Edited September 20 (6 years ago)

Noon said:

Sorry it took so long to respond, I was running a game.
So some of the features work but the options menu isn't on the side? Are you sure you're using the most recent version? Also you can tell it is activated in tampermonkey if it looks like this
 

If so, can you PM me what your console says?
(Press F12 and copy/ paste what's in the console tab from when the page has finished loading up to the top)

Thanks to Anthony I managed to fix a bunch of bugs and also
I added a new feature. It looks like this. Setup details are in OP.


September 20 (6 years ago)

This is pretty unbelievable. I'll definitely want to take a look at this, especially the Toolbar Macro. So I understand though, that would require the sheet to have a macro button that displayed all of the attacks, skills, etc. like the Pathfinder Community Sheet has and the 5e OGL does NOT? That looks so freaking cool.

September 26 (6 years ago)

Edited September 29 (6 years ago)


Noon said:

You could pretty easily just create macros or abilities for any system and put them there. Pathfinder Community Sheet is just convenient because it auto-generates them for every character.


Will create a two button dropdown.
One calls the macro "Description".
The other calls the ability on Grognard's character sheet called "Rage-On".
They don't auto-update so just reload the page when you change the ToolBar macro.

I added a feature where you can use those quickmacros like before but they can be javascript as long as you put j: before the code.
For instance, this

||Edit Repeating||j:(function() {var tabbed = _.max(document.querySelectorAll('.ui-dialog.ui-widget'), o => o.style.zIndex); $(document.elementFromPoint(tabbed.offsetLeft + tabbed.offsetWidth / 2, tabbed.offsetTop + tabbed.offsetHeight / 2)).closest('.sheet-repeating-fields').find('.btn.repcontrol_edit').click();})();

will toggle reorder/ delete mode on the repeating section visible on the topmost visible character sheet in the pathfinder community sheet.
No more scrolling down to the bottom of the equip tab to delete some dumb item only to scroll back up to the 13th slot.

This is a pretty grey-area feature though since you could use it to theoretically distribute code to other people's computers (they would still have to load up this userscript and then click the button still) but it begs the question: Should I include a warning and make it off by default? That's probably overkill... right?

Anyways newest version also includes some fixes for bugs Anthony V. discovered (he's on like 6).
And a fix for a bug in roll20 nobody seemed to notice: Token names are drawn twice sometimes. once on maincanvas and once on upperCanvas.

October 02 (6 years ago)

Have you seen what Stardust the Super Wizard has done with browser scripts? You two have done some really remarkable stuff.

October 02 (6 years ago)
GiGs
Pro
Sheet Author
API Scripter

It's not Stardust who created that, he just pointed out where it is.

October 02 (6 years ago)


G G said:

It's not Stardust who created that, he just pointed out where it is.


My bad. Either way, both great sets of tools.

October 02 (6 years ago)

I've seen it, yeah. I'm going about things in a different direction (namely I don't have access to internal engine functions, API, extension calls, or pre-load. I need to keep it bookmarklet friendly, sadly). My code is fair game to stormy or anyone for that matter.

Regardless, I implemented something cool. Icons are going to take a bit longer but progress is progress.


October 11 (6 years ago)

Noon said:

Roll20 Fixes and Improvements

or: How I Learned to Stop Worrying and Love the Bomb

OwO you're amazing! keep up the awesome work!