Skip to content
TORNLIFE More

[userscript] OC Icon API - BROKEN

Started by PsycWard [1579270] on in Tools & Userscripts.

36 replies · 1.7k views · thread synced · 6 days ago · View on torn.com
About this thread

Posts archived: 37 / 37 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
37
Discussion span
→
Authority score
58 / 100
Historical score
41 / 100
Story score
52 / 100
Engagement score
73 / 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

PsycWard [1579270]

A faction mate said something in chat about wanting to create an icon that showed organized crime time. So I wrote this, it pulls data from the API and adds it to the faction icon. The script only updates when pages are loaded so it won't constantly update unless you make it. Also if icons refresh which seems to happen every 5 minutes with Nerve it will revert back to normal.

If you download the script you will have to find var API=""; in the script and enter your API key. You will also need API perms from your faction.
The similar name problem of the old version should no longer exist thanks to the API displaying user ID. As usual I have tested this on Chrome, I don't use FF or any other browser so if it doesn't work for other browsers sorry. If you experience issues with FF removing the @require line may solve the problem.

If you have an issue explain your problem, I will simply ignore posts that say it's not working.
Your browser and what the exact problem is should be included. If you can't be bothered to tell me that, I can't be bothered to look into your problem.


[image: i.imgur.com]



OC Icon API stores the OC data in a cookie for repeated use without calling to the torn server. This information will then be displayed when hovering over the faction icon the same as above but will still show after the text is cleared out when the icons refresh. In addition I've added a feature that will estimate OC time while traveling. To update the time while travelling refresh the page.
I have traveled a few times, as of right now it seems to be accurate to the minute but there maybe bugs that I don't know about. This does use a jQuery cookie library so I don't know if GM users will experience problems or not.

[image: i.imgur.com]

OC Icon API


boo [1544641]

Try this instead:

// ==UserScript==
// @name OC Icon
// @namespace http://www.browserscripts.blogger.com
// @author PsycWard
// @include http://*.torn.com/*
// @version 0.1
// @require http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js
// ==/UserScript==

$.ajax({type: 'post',url: 'http://www.torn.com/factions.php?step=your#/tab=crimes',data:{step: 'crimes'}}).then(function(data){
var fT=$(data);
var tempTime=fT.find("li.team:contains('REPLACE YOUR NAME HERE')").siblings("li.status").text();
if (tempTime.length>0){
var ocTime= "<br/>OC - " + tempTime;
var facI=$("#icon9").attr("title");
$("#icon9").attr("title",facI+ocTime);}
});
PsycWard [1579270]

I have not been able to replicate the problem so far. Are you using Chrome? Do you have developer tools? If so open developer tools and then click on the console tab. Do you see any errors?

On a side note I did see that the script was running twice in a row for me, once for factions.php then again for /includes so I have added a line to prevent it from running again on includes.
Related to traveling I originally kept the script very simple and did not have a step to make sure the faction data loaded. While traveling you can't access faction data and an error page is given instead. I've added a step now that will stop the script if the faction page is not loaded but I will need to get back to torn to test it.
Harley [258120] Wiki Contributor

the original script works fine for me, even when flying. The timer still works..

It would also be nice to have like a little timer added which you can configure, that's like under the little plane. So we can see how long till the next oc is coming, just throwing an idea !


edit: this script is the best by the way.. This should significantly reduce the amount of OC - fines I get xD
PsycWard [1579270]

Thank you.
I made a version that stores the last loaded time to a cookie so that when the icons refresh the "OC - (time)" doesn't disappear. I was going to add it but I get pretty lazy with this stuff these days. I could easily add "OC Time as of Departure - (time)" to the travel page. Creating something that attempted to give a somewhat accurate current time while traveling might be a little more difficult but I'll put some thought into it, since it does seem like a good idea.
PsycWard [1579270]

I'll switch the name and see what I can find.

Edit: I'll have to wait there are none 100+ right now. Which browser and script are you using? What is does the display look like and is the problem with the icon, while traveling or both?

Edit#2: I'm now in a 100+ crime and I see no problems OC Icon C.
[image: i.imgur.com]
[image: i.imgur.com]




PsycWard [1579270]

Edit: Okay, I looked at it a bit and I think it's the same reason tornstats script doesn't work on https.
I believe while using https it doesn't allow http connections. So if you have the cookie stored already (by using http://) it will work to an extent. If you use https all the time you may want to try adding a "s" to url: 'http://www.torn.com/factions.php' in the script. I don't use https so it hasn't been a problem for me.
PsycWard [1579270]

I just tried both links, they both worked for me. Are one of the links not working, if so which one or once installed the script isn't working?