Skip to content
TORNLIFE More

[Userscript] Activity Log filter & export

Started by Lugburz [2386297] on in Tools & Userscripts.

24 replies · 2.29k views · thread synced · 3 days ago · View on torn.com
About this thread

Posts archived: 25 / 25 posts (100%) · the total is Torn's reply count + the opening post at the last fetch

Counted by TornLife from the archived posts.

Archived posts
25
Discussion span
→
Authority score
58 / 100
Historical score
46 / 100
Story score
54 / 100
Engagement score
74 / 100

People posting, likes and official posts are not counted for this thread yet: on threads longer than one page they come from a periodic pass over the archive, which has not covered it.

Most-liked replies

Lugburz [2386297]
In the absence of long-awaited functionality of searching the activity log, as well its availability through the API, I finally got around to creating a userscript that's intended to fill some of the gaps.

The userscript has three features:
  • Exporting logs from the Log page (since version 0.3).
  • Filtering the activity log by one or multiple of 49 (!) categories - 49 is how many I was able to find in my logs for the past month. Please let me know if any category is missing, thanks!
  • Exporting the log as a CSV file (that can be imported into Excel or Google sheets or some other spreadsheet app). Unfortunately, it's only possible to export those log entries that are visible to the user (since non-API automatic requests are not permitted), so make sure to scroll the list down as far as you need before clicking "Export".
  • It's possible to export all log messages or only the ones that are filtered - this is controlled by the "exportAll" variable value: "true" for all messages, "false" for filtered messages only.
As always, donations are welcome and appreciated. ;)
Please let me know if there's anything in the script you'd like to be added and/or improved!

Installation link: https://github.com/f2404/torn-userscripts/raw/master/activity_log_filter_export.user.js

1) Export logs from Log page
Since version 0.3, it's possible to export logs from the recently introduced Log page.
This works in a way that all log entries that are in the page (including both visible and those hidden under "similar") will be exported. This means that you still need to scroll down the page; and whatever filters you have applied, the same filters will be applied to exported logs.

[image: i.imgur.com]

2) Filtering
Filtering is configured through the "visibleCategories" list in the script. If the list is empty, all categories will be visible (default).
There's a full list of categories below.

[image: i.imgur.com]

3) Export
There is an "Export" button in the Tampermonkey menu under the script name. When clicked, a standard open/save file dialog will be displayed.
Remember to open the activity log before clicking the button!

[image: i.imgur.com]
Lugburz [2386297]
Version 0.2 adds category for Christmas Town ("Christmastown") add an ability to only export filtered messages.

Set "exportAll" variable to "true" to export all messages (this is the default behavior) or "false" to only export filtered messages.
Rescender [2526540]
Haven't even tried it yet but here are some categories you are missing:
Bail, Books, Bounties, Donator, Happy, Job, Loan, Seasonalgift, Tokenshop

I've used a rather lengthy process and downloaded my whole history using postman collection runner and a local run server to store json files (over 6500 to be blunt). My process probably missed some as I'm only looking every hour and if there are more than 100 events in an hour, I missed them. I'm guessing I got 99% of them though. Then imported all of them to a database so I can query anything I want to see.
DeKleineKobini [2114440] Committee Committee
What you are doing is not allowed and against the rules. You can't collect non-api data that you didn't obtain from the page you are looking at.
Rescender [2526540]
Always DKK to be the party pooper. Yes, you are probably right. It's not something that I should have done, but also not something that gives an advantage in any way. But if people like me are willing to go to these lengths to see our activity logs, that says something.

The nerd in me simply wanted to see how many drug packs i've opened and how many times I got xanax. It evolved into something much more complex and useful. But hey I'm at about 74% xanax pulls!
DeKleineKobini [2114440] Committee Committee
I do understand why you'd want to do it, I also want access to that data, and we don't know when it will be added to the api, only that it will.

That doesn't mean you should break the rules for it though. If you want access to the data, you should suffer, like all of us.
Lugburz [2386297]
This is all nice, but, as DKK pointed out, completely illegal, unfortunately.

Thanks for the categories, though! ;)
Rescender [2526540]
Np, some of those categories only had like 1 total entry so unless I had all the data I probably wouldn't have caught them.
But I won't be doing it anymore, per the legality of it I guess. Was fun anyway.
Rescender [2526540]
Oh, I was also very disappointed that the ID property on the activity log entries was not persistent to that entry, the same entry will have a different ID every time you reload the activity log. Unique globally, yes. I'm not sure I understand that design decision. Time and text together were distinct enough though. Except for when you are spamming crimes or eating candy, it's still possible to have 2 entries that happened within the same second with the same text. /shrug
Lugburz [2386297]
Yeah, I didn't understand that, too. IDs that change every time the log loads don't make sense to me.
Helcostr [1934501] Wiki Editor
best recommendation to not suffer is to block all entries but 1 from appearing in the list (ingesting the rest), and have the built in auto scroll on (middle mouse button).

Blocking all but 1 allows the list to be refreshed (since u hit the bottom faster)

Auto scrolling is allowed, last i checked with IBF.
Darkfleet30 [2636278]
Fantastic script. Well done!
However, as stolen from bzzt above, would only require a few small tweaks to remove messy html tags from some descriptions, plus show both utc time and local user time.
Another handy addition would be the current time appended to csv filename, for people who might want to regularly export logs for analysis and want unique filenames etc.

function exportLog() {
if (!logs.size) {
alert('Please open the activity log first');
return;
}

let csv = 'timeUTC,timeAU,Category,Description\n';
for (const l of logs) {
const time = new Date(l.time * 1000);
var foo = l.text.replace(/]*>?/gm, '');
csv += [`"${time.toUTCString()}"`,`"${time.toLocaleString("en-AU")}"`, l.category, `"${foo.replace(/\n/g, ' ')}"`].join(',') + '\n';
}
const myblob = new Blob([csv], {type: 'application/octet-stream'});
const myurl = window.URL.createObjectURL(myblob);

var n = new Date();
var csv_time = n.toISOString().slice(-24).replace(/\D/g,'').slice(0, 14);

const ancorTag = document.createElement('a');
ancorTag.href = myurl;
ancorTag.target = '_blank';
ancorTag.download = 'activity_log_' + csv_time + '.csv';
document.body.appendChild(ancorTag);
ancorTag.click();
document.body.removeChild(ancorTag);
}
Darkfleet30 [2636278]
Also a handy hint to anyone who wants to use this script to do a once off dump of their full history. Zoom your browser to 90% before expanding the log. It will scroll down by itself indefinitely. Just export it once it's done.
Rescender [2526540]
Yes! now it needs to be adapted for the new log page! A shame for this to become obsolete. Having it with added functionality would keep it relevant.