track lateness to online meetings

Thanks for kindly offering to help on this. Figured I’d follow up. @zedmango, @adamwolf

Well a tampermonkey script could send data to beeminder when you go to the URL; would that be enough?

1 Like

Yes. Now I would just need the script.

Thanks again for offering to help, @zedmango . Figured I’d follow up - when you get a chance.

1 Like

@zedmango, @adamwolf was it something I said? :wink:

1 Like

I’m sorry if it seemed like I was commiting to writing a custom integration. I can’t commit to that right now. I wish you good luck–it seems like it is at least technically possible!

aww @adamwolf I was wanting to see how many more times he’d keep asking if we didn’t respond :stuck_out_tongue:

@aturetsky - try this. Replace “www.zoom.com” with the actual URL. You may need to put in http:// or https:// first - I’m not sure.

You will also need to put in your authentication token where it says “myauthtoken” and the name of your goal where it says “mygoal”.

If you need more help check here: GreaseSpot Wiki

// ==UserScript==
// @name     Beeminder
// @version  1
// @grant    GM.xmlHttpRequest
// ==/UserScript==

if (document.URL == "www.zoom.com")
{
GM.xmlHttpRequest({
  method: "POST",
  url: "https://www.beeminder.com/api/v1/users/aturetsky/goals/mygoal/datapoints.json",
  data: "auth_token=myauthtoken&value=1",
  headers: {
    "Content-Type": "application/x-www-form-urlencoded"
  }
});
}

@aturetsky Does that work? Let me know if there are any errors and I’ll help debug.

2 Likes

So sorry for such a delay in reply, @zedmango. I was traveling and couldn’t try this right away. Thanks so much for your help! Okay, so I figured out how to use Tampermonkey and how to create and install scripts. I also think I understand the values that you’d like me to replace to the relevant placeholders with. Here’s a question, though - what type of a goal should I be choosing on the https://www.beeminder.com/new page - from what I understand it needs to be a type of a goal that would end up being tracked in a datapoints.js page that will end up being hit using your script via an API - so do I select “add progress manually” or “connect to a service, .etc.” ?

1 Like

Do More, rate 1/year (since you’re just using it to track, the rate and type don’t really matter, but you want something that won’t derail on you)

Select “add progress manually”

And then go to Settings, go to the fifth Settings panel (which confusingly is also called “Settings”), go to “Data,” and choose “API” there.

Thanks, @zedmango. I went ahead and did all that and installed the script. Hitting the url didn’t result in any change in beeminder stats. I coudn’t find a log in either beeminder or tampermonkey, so I ended up just trying to see what happens if I type this right into the address bar - here’s what I got.

I typed:
https://www.beeminder.com/api/v1/users/aturetsky/goals/test1/datapoints.json?auth_token=vb1hFU4JpXpyU-xYE…&value=1

And I got:
[{"timestamp":1591303673,"value":0.0,"comment":"initial datapoint of 0 on the 4th","id":"5ed95df93b53bf26d300b...","updated_at":1591303673,"requestid":null,"canonical":"04 0 \"initial datapoint of 0 on the 4th\"","fulltext":"2020-Jun-04 entered at 15:47 ex nihilo","origin":"nihilo","daystamp":"20200604"}]

And of course, I used the appropriate token, but am replacing the last three digits with … here for security purposes.

So you tried hitting the URL directly a few times and it didn’t change the beeminder info? Did you give it a few minutes and reload the beeminder goal page to check?

Double check the goal name, auth token, and goal settings for “API” as data source.

@dreev, @adamwolf - is there some step I’m missing? Does he have to do anything else to allow API access?

I think it needs to be a POST instead of a GET, but I am on mobile and cannot check easily.

2 Likes

Oh, yes, that’s right - @aturetsky, entering it in the address bar won’t work because the browser uses GET instead of POST.

So we need to make sure the script is enabled in tampermonkey - is there a way to do that?

1 Like

Can you try for me:

  1. Find some other tampermonkey script and load it, to make sure tampermonkey works?

  2. Delete the line in my script that starts with “if” and the two outermost braces, and see what that does?

So the script would then say:

// ==UserScript==
// @name     Beeminder
// @version  1
// @grant    GM.xmlHttpRequest
// ==/UserScript==

GM.xmlHttpRequest({
  method: "POST",
  url: "https://www.beeminder.com/api/v1/users/aturetsky/goals/mygoal/datapoints.json",
  data: "auth_token=myauthtoken&value=1",
  headers: {
    "Content-Type": "application/x-www-form-urlencoded"
  }
});

You may need to change the URL in the script - it may need an “http://” or “https://” in front.

The other thing you might try is changing “document.URL” to “document.location” and see if that does anything.

I was, in fact, doing it as a POST request - as I was using Tampermonkey. And yes, other scripts do work in Tampermonkey. (I only tried it as a GET request afterwards, since I couldn’t find any logs in either Tampermonkey or beeminder.)

I went ahead and took out the if clause, as you recommended and then went to a random url. I assume that would get the script to trigger. And yet, no change in the beeminder statistics. Is there a log anywhere or at least a way to see if the script even triggered.

Thanks!
Alex

Ok can you please double-check the following:

  • is the script set to trigger in tampermonkey when any webpage is loaded?

  • are the goalname and auth token correct?

  • is the goal set under settings to allow “API” as a data source?

  • if you close and reopen the browser, load some pages, wait a few minutes, go to the beeminder goal page, and reload it, is the data still missing?

I just want to make sure we’re not missing something obvious.

Oh, also - can you try it in Firefox with the Greasemonkey add-on and see if it works there?

Just tried it in Greasemonkey on Firefox and still doesn’t work.
As far as waiting a few minutes - I am pressing a refresh button that’s on the goal page in beeminder that’s right next to the text that says 'This goal gets its data automatically from the API." So I assume that would load in the latest data.

As to the questions to double check. I double checked everything except for this:

is the script set to trigger in tampermonkey when any webpage is loaded?
How can I tell? I tested tampermonkey on other pre-existing scripts (like for instance one that redirects amazon.com to smile.amazon.com and that works, but I am not sure how to easily write my own script that I can use to simply confirm the fact that it will get triggered on every page.) And again, is there no log for greasemonkey or tampermonkey just to see that it even triggered?

Did you try the version without the if-statement on Greasemonkey on Firefox?