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

Use a Macro to post a Time Stamp into chat.

1559365714
Mike W.
Pro
Sheet Author
Without turning on Time Stamp in the chat, because it clutters it up, is it possible to use a macro to post the current Time Into chat on its own? I have an ability that can only be used once per hour real time so I want to click that ability and have it post the exact time I used it into the chat.
1559376411
GiGs
Pro
Sheet Author
API Scripter
I'm not aware of any way to do that, other than an API script. There might be a timer script already made which lets you set timers.
1559380714
Mike W.
Pro
Sheet Author
OK thanks GiGs, I was suspecting that.
1559389579
The Aaron
Roll20 Production Team
API Scripter
It's a very simple api script, the most complicated part is you'd need to tell it what time zone you want. 
1559421615
Mike W.
Pro
Sheet Author
The Aaron Unfortunately the game I am in that I need it for is run by a GM with a free account. Thank you so much for your responce. Mike
1559469074

Edited 1559469329
Finderski
Pro
Sheet Author
Compendium Curator
You could create a macro like this: /em uses ability at ?{What's the time?|} Add that to your macro bar...? Edit: If you need to know the seconds, you could use this website (if you don't have something else easy to get the info):&nbsp; <a href="https://time.is" rel="nofollow">https://time.is</a>
1559473226
Mike W.
Pro
Sheet Author
Yeah I already had that. I was just trying to find a way to make it auto timestamp (I should have been more clear).
1559483289
The Aaron
Roll20 Production Team
API Scripter
Is it you that needs to output the timestamp at certain points, or some other player(s)?
1559486674
Mike W.
Pro
Sheet Author
Just for me when I click one ability. I need to note the time the ability was used, others (except for the GM) do not need to see the timestamp. Even the GM is optional, she trusts me to keep track. She is not a Pro account s a script will not work. I can live using a Select Query.
1559490371

Edited 1559490472
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
If you are using Chrome, this might be doable with a bookmarklet ? (I couldn't write one, but the premise sounds valid). Note that this would not work on Firefox, which does not allow JavaScript to be used this way.
1559491228
Mike W.
Pro
Sheet Author
I am using Chrome but what you suggested is above my pay grade - thanks for all f the ideas.
1559491246
The Aaron
Roll20 Production Team
API Scripter
If it's just for you, there's an extension similar to Stylus except for site specific Javascript.&nbsp; It would be possible to write something that would detect the need for a timestamp on your local browser instance and then whisper it to you or the GM.&nbsp; I've not messed with it too much, but it could be pursued if you're Javascript savvy.
1559492737
Mike W.
Pro
Sheet Author
No I am not Javascript savvy. I do appreciate all this but it is to much effort for such a small thing. The select query will suffice. Thanks again.
1559499164
The Aaron
Roll20 Production Team
API Scripter
Ah, I already wrote it. =D This extension:&nbsp; <a href="https://chrome.google.com/webstore/detail/custom-javascript-for-web/poakhlngfciodnhlhhgnaaelnpjljija" rel="nofollow">https://chrome.google.com/webstore/detail/custom-javascript-for-web/poakhlngfciodnhlhhgnaaelnpjljija</a> This code: const sendChatMsg = _.debounce((msg) =&gt; { $('#textchat-input textarea').val(msg); $('#textchat-input .btn').click(); },300,true); const onAddToChat = _.debounce((mutations) =&gt; { let send = false; mutations.forEach(m=&gt;{ if(m.addedNodes){ m.addedNodes.forEach(n=&gt;{ if(n.childNodes){ n.childNodes.forEach(c=&gt;{ if(/^\s*TIMESTAMP\s*$/.test(c.data)){ send = true; } }); } }); } }); if(send){ let d = new Date(); sendChatMsg(`/w gm *Timestamp:* ${d.toLocaleTimeString()}`); } },300, true); const tsObserver = new MutationObserver(onAddToChat); setTimeout(()=&gt;tsObserver.observe($('#textchat .content')[0], {childList: true}), 10000); This command in chat: /w "Mike W." TIMESTAMP (or whatever your player name in in the game) will result in whispering a timestamp to you and the GM:
1559500820
Mike W.
Pro
Sheet Author
Aaron I paste the script and saved it - but when I reopen to check, it only has this const sendChatMsg = _.debounce((msg) =&gt; {
1559501687
The Aaron
Roll20 Production Team
API Scripter
That seems to be a bug in the extension. As long as you pasted it in there and saved it, it should work.&nbsp;
1559502010
Mike W.
Pro
Sheet Author
I am sorry to say it is not working for me. All I get in chat is this. When I click save, the site refreshes and during that time if I open the box again the code is there. The moment the site is up then I get that error when I reopen the input box.
1559502035
Mike W.
Pro
Sheet Author
By the way I am testing it in a game that I own and GM.
1559502211
The Aaron
Roll20 Production Team
API Scripter
Hmm. It just looks for a change in the chat box, checks to see if a message was added with just TIMESTAMP in it, then sends the whisper.&nbsp; Did you check the "enable for this site" checkbox?
1559502251

Edited 1559502278
The Aaron
Roll20 Production Team
API Scripter
Also, it has a 10 second delay before it is active (I.e. parsing messages), to prevent it from spamming on load of the chat.&nbsp;
1559502498
Mike W.
Pro
Sheet Author
Yeah the box was checked automatically. I verified it has access to the site
1559506683
The Aaron
Roll20 Production Team
API Scripter
Hmm...&nbsp; Try this version and see if you console logs in the Chrome Javascript Console that say "onAddToChat) - called": const sendChatMsg = _.debounce((msg) =&gt; { console.log(`sendChatMsg() - Sending: ${msg}`); $('#textchat-input textarea').val(msg); $('#textchat-input .btn').click(); },300,true); const onAddToChat = _.debounce((mutations) =&gt; { console.log(`onAddToChat() - called`); let send = false; mutations.forEach(m=&gt;{ if(m.addedNodes){ m.addedNodes.forEach(n=&gt;{ if(n.childNodes){ n.childNodes.forEach(c=&gt;{ if(/^\s*TIMESTAMP\s*$/.test(c.data)){ send = true; } }); } }); } }); if(send){ let d = new Date(); sendChatMsg(`/w gm *Timestamp:* ${d.toLocaleTimeString()}`); } },300, true); const tsObserver = new MutationObserver(onAddToChat); setTimeout(()=&gt;tsObserver.observe($('#textchat .content')[0], {childList: true}), 10000);
1559579511
Mike W.
Pro
Sheet Author
This is what I see in the log immediately after I run the timestamp Finished after going 2 levels deep. 13317dbe-7d37-4969-90e9-aedb2e59c4b2:584 13317dbe-7d37-4969-90e9-aedb2e59c4b2:584 Begin processing op! 13317dbe-7d37-4969-90e9-aedb2e59c4b2:584 Inline rolls complete! No mention of&nbsp;"onAddToChat) - called"
1559580769
Mike W.
Pro
Sheet Author
I even tried CJS 2 which looks like a more up to date extension then the one you gae me, but that did not work either. However at least the code does not disappear when I reopen it.
1559597524
The Aaron
Roll20 Production Team
API Scripter
Hmm.. I'll have to try that one.&nbsp; I didn't have to make any changes to the extension to get it running and I literally installed it to try this out.&nbsp; I'm on a Mac, but that shouldn't make any difference to Chrome.&nbsp; Could be I have something turned on for developer mode that would allow it to operate without explicitly granting it extra permissions, but that seems unlikely.
1559601064
Mike W.
Pro
Sheet Author
I am on a PC Windows 10, latest Chrome, I even tried 2 other Java injectors and nothing worked.