Skip to content
TORNLIFE More

[Script] My Torn Time Table

Started by BypXByp [3243346] on in Tools & Userscripts.

24 replies · 1.36k views · thread synced · 5 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
38 / 100
Historical score
33 / 100
Story score
49 / 100
Engagement score
69 / 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

Mentioned in this thread

Mythia02 [2669499] ×2 Titanic_ [2968477] ×2

BypXByp [3243346]

I've been playing for almost 2 months and I still struggle with the time zone differences - all I know is new day is at 7 PM for me.

Sometimes doing the math quick in my head works, but THEN if I need to math the math - i.e. figure out "9 hours from now" - I just give up.

So, I made a thing. Maybe this will help someone else. Cheers.


My Torn Time Table gets the time zone from your browser, then uses that time to generate a conversion table between TCT and your local time, and a chart of the next 23 hours for easy adding.

I'm sure the code could be a little cleaner, JS is not my forte, but it's simple and it works.

To install:

  • (Torn PDA users see the second 'Note' below)
  • Get the script on Greasy Fork here: My Torn Time Table on Greasy Fork
  • No need to do anything, it auto-detects your time zone!
  • Optionally, you can edit line 19 of the code to toggle if you'd like the table to auto-expand when you open the clock or load a page.

Notes:

Screenshots:
[image: greasyfork.org] [image: greasyfork.org] [image: greasyfork.org]

Updates/Version History

v0.4.0 - May 24, 2024

  • Added run-at key so script runs sooner, hopefully enabling Torn PDA support.

v0.3.3 - May 19, 2024

  • Minor script cleanup after some testing, no operational changes.
  • Greasy Fork requires me to make an 'update' to add screenshots, so...

v0.3.2 - May 12, 2024

  • Fixed bug that resulted in negative time differences
  • Added variable to toggle if you want the table to auto-expand

v0.3.1 - May 12, 2024

  • Added link to toggle the visibility of the table, thanks to Mythia02 [2669499]
  • Added tweak to align the columns nicer
  • Removed a couple lines of code I left from debugging

v0.3 - May 12, 2024

  • Released

Known Issues
None known at this time.

Mentions: Mythia02 [2669499] · Titanic_ [2968477] · [Script] My Torn Time Table

Mythia02 [2669499]
Add this into line of code. works for me

[image: i.snipboard.io]
Code:

<div><a class="toggleCollapseTimeTable">Toggle</a></div>




[image: i.snipboard.io]
Code:

function waitForElementToExist(selector) {
return new Promise(resolve => {
if (document.querySelector(selector)) {
return resolve(document.querySelector(selector));
}
const observer = new MutationObserver(() => {
if (document.querySelector(selector)) {
resolve(document.querySelector(selector));
observer.disconnect();
}
});
observer.observe(document.body, {
subtree: true,
childList: true,
});
});
}



[image: s3.amazonaws.com]


waitForElementToExist('.toggleCollapseTimeTable').then(()=>{
$('.toggleCollapseTimeTable').on('click', function() {
console.log("OK===========");
if ($('#tableOK').css('display') == 'none') {
$('#tableOK').css('display', '');
} else {
$('#tableOK').css('display', 'none');
}
})
})
BypXByp [3243346]
Oh thanks. I was looking for a way to close the whole default time bar - looks like this will leave that bar open and just collapse the additional table, right?

Where are you adding the function code - your middle screenshot - tried a few places and I'm getting a few errors in the editor. Also, do I need to add 'tableOK' as the class for the table? I'm assuming so but don't see that you added it.

Thanks for adding this, if I get it working I'll make sure to credit you on the script as well.
BypXByp [3243346]
Got it working. Updating the script and OP.

Also did a little bit of cleanup with a few lines I had left in there for debugging.
BypXByp [3243346]
And version 0.3.2 is out lol; OP and Greasy Fork are updated.

v0.3.2 - May 12, 2024
  • Fixed bug that resulted in negative time differences
  • Added variable to toggle if you want the table to auto-expand
You can edit line 18 of the code to toggle if you'd like the table to auto-expand when you open the clock or load a page.
BypXByp [3243346]
Tried a few more things for TornPDA, I've done some playing and testing but can't get it working. On PC/web browser the script needs to run after the page fully loads, and for whatever reason TornPDA doesn't reach the point that this script thinks the page is fuilly loaded, so it never triggers. If someone can figure it out I'm happy to update the code - again, JS is not my forte, and I don't use TornPDA so I can't do my own testing.

Minor update published
v0.3.3 - May 19, 2024
  • Minor script cleanup after some testing, no operational changes.
  • Greasy Fork requires me to make an 'update' to add screenshots, so...
Kwack [2190604]

Scripts without the run-at directive will inject at document-end by default to prevent against unexpected behaviours.

 

The document would have loaded (and hence the event would have been fired) before the event listener is registered, hence why it never triggers.

 

You'll need to either tell the script to inject at document-start (where it can listen to the event), or you'll have to mark the script as document-end (for PC) and call the function directly.

BypXByp [3243346]

Interesting okay.  I'll give that a shot when I get home at the end of the week and find a TornPDA user to test.  Thanks Kwack

BypXByp [3243346]

Looked in to the run-at key proposed by Kwack and dug around for a bit for anything else that may affect Torn PDA.  Added the run-at key to make sure the script runs right away and, I think, that should make this work on Torn PDA.

 

v0.4.0 - May 24, 2024

  • Added run-at key so script runs sooner, hopefully enabling Torn PDA support.
ThunderBlitz [2684774]

I tried offering some insights with TornPDA use and, the dude blocked me.  I guess I misinterpreted his public plea for assistance with it.  shrugs

 

In any case, I found that it did work in TornPDA, just not initially, when you (for example) refresh the page.  Instead, if you hit the back button (assuming you have previous pages you've visited), then it works as expected.  It continues to work, unless you disable the script and reload the page.

 

However, after I updated it to v0.3.2, it developed a visual glitch where the chart almost repeats from the bottom and, the toggle button no longer works (it did in the previous version, I'm assuming 0.3.1).  The only issue that persisted in both is that the 'Local Time' is static, it loads the time the page loads at but, doesn't update in real-time.  He's acknowledged this privately and honestly, it's not a huge issue, as most have the current time visible at the top of their phones anyway, so it's easy to workaround.

 

This response is mainly for Kwack, so you've got a fuller picture of how the script has performed.

 

I'm reluctant to try the newer versions, which have been claimed not to work, as the version I have is at least functioning on TornPDA at the moment.

 

BypXByp [3243346]

I blocked you because you said the same thing, in 20 different ways, across 40 paragraphs, in 15 messages.  Slight exageration on the numbers, but close enough.

 

This is less of a "public plea for assistance" and more of a "hey, people want it to work in Torn PDA, so let me know what to try."  I don't use Torn PDA, so it's of no use to me.  My efforts of trying to make it work in Torn PDA - much like sharing this script at all - is just a matter of trying to be nice and hopefully help someone.  While I appreciate the feedback and your information, I didn't appreciate your spammy messages and your now condescending attitude.

 

As I stated in OP, JS is not my forte.  I do a bit in Perl, VBS, and Powershell for work - and even that is a matter of Googling stuff half the time.  I was shocked this worked at all, to be honest.

 

To respond to your couple points here.  Yes, the local time is static - it just grabs it when the page loads then does the math.  And yes I acknowledged it privately, but also publicly... maybe go check OP and the details on Greasy Fork.  As for it only working on refresh or using the back button in Torn PDA, as I told you in the messages and shared in the comment Kwack responded to, I can only assume that behaviour is because of when the script runs and how/when it grabs the time, and therefore by using the 'back' button the information is already there for the script to use.  That also would explain your duplicate table issue, where it displays a second time after you use the back button, because the script then seems to run multiple times - again, likely a timing issue.  I actually considered just figuring out how to make the script wait 1 second or something then running to see if that helps.

 

I agree, no sense in trying the new version as someone else already has and said it doesn't work.  But if you do, remember you can always see the revision history on Greaasy Fork and edit the script yourself to revert to an old version.  You can also try playing with it yourself to see if you can get it working, that's one of the joys of open source user scripts.

 

Plenty of other scripts and extensions aren't compatible with Torn PDA, not sure why you picked me or mine to harass.  As this works as I intended it to on browser, I'll leave it at that, and stop trying to please everyone.

BypXByp [3243346]

Oh right!  I was traveling for work when you sent this then lost track of it after a bunch of other mails.

 

If this works for Torn PDA you're welcome to keep it up and others are welcome to use it, of course.