Dev_User_inf

displays current status of users and if you're watched by them

  1. // ==UserScript==
  2. // @name Dev_User_inf
  3. // @namespace Dev_User_inf
  4. // @version 3.34
  5. // @description displays current status of users and if you're watched by them
  6. // @include http://*.deviantart.com/*
  7. // @include https://*.deviantart.com/*
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js
  9. // @grant GM_getValue
  10. // @grant GM_setValue
  11. // @grant GM_xmlhttpRequest
  12. // @grant GM_registerMenuCommand
  13. // @grant GM_log
  14. // ==/UserScript==
  15.  
  16. (function(){
  17.  
  18. // var $=unsafeWindow.jQuery,holder,query,offset,fPage,pPage,lPage;
  19. if(typeof $ == "undefined")return;
  20.  
  21. // var ownusername=$("td#oh-menu-deviant.oh-hasmenu a.oh-l b");
  22. var ownusername=$("td#oh-menu-deviant span.username-with-symbol span.username");
  23. if(ownusername.length==0){GM_log("Not logged in!");return true;}
  24. var fremdusername=$("div#deviant.bubbleview div.catbar div.gruserbadge h1 a.u");
  25. var watchbutton=$("div#deviant.bubbleview div.catbar div.gmbutton2town a.devwatch");
  26. var imgoff="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs%2B9AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A%2FwD%2FoL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sKEAY7AeG8qm4AAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAAAMpJREFUGNONkEsKwkAMQN%2B0MwyWCgqCgivxLO68gWtv5VK8g0fwJm7U0g46Y61xM36qG7NJAi8JeYp2yFevfgpAdtMp%2FfGY7nCIsZbBev1ikie0zXNsltHp9chGI%2FLJBLdcvq4kgGzimAKUCEqEVIQE2M9mAKIBGuDqPVfnCEWBt5b76UTjHKEsAdAANRBuN6rDAa014j3aGBrvOR%2BPb%2FAOXIC0LJG6xhcFRmuaELhUVetrWQEW6MScxgXzaKelZxUnTQQXHwrVv8IfaUNM0cocy0wAAAAASUVORK5CYII%3D";
  27. var imgsemioff="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs%2B9AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A%2FwD%2FoL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sKEAY7EfwLugoAAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAAAN9JREFUGNONkD1PwzAQhh%2FHNm6j8lEJCSTEgPgtbOwMzP1DnTMiRnYmZv4EMxICShOIncQ%2BBotWgYVb7kPPvad7FeOQX736UwDy%2BHDOfH7C7v4R1jgOT282TPED3d%2FNcJOSaXlAWR4z2zujeVlsrhSA3FagVF5VSlBK0FooCnh%2BugAQAxAjdJ2n6xqCX%2BF3HCm%2BE4eGENYAGIC%2BhxAG6voVYwySPMZa4uD5%2BnzbgilB60F%2FrJHU49sV1hriEGjbevS1VEtwDqaTnLXOApdXmRvZUy3zxNoMXi%2B2Yuq%2Fhn8D%2B3VTT5NgdoYAAAAASUVORK5CYII%3D";
  28. var imgon="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs%2B9AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A%2FwD%2FoL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sKEAY7Hxuzlw0AAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAAAN5JREFUGNONkE1KxEAQhb9KumkyjDMK4ogKIt7AO7hz6c61F%2FAybmYp3sEjeBMRjPkb0z2xUy6iM0Q3FhRUwffqUU8Yl%2F7a5c8A6MXzOUd7xxzsLHDWcb%2F%2FsGGSH%2BjkaUrmJsyzXRaTQ06nZ9w1txuXBND547dOQEWHThUSuH65BFADQIR27VmtG8pQ8OodRf%2FOKjZUoQLAAGgHMXyS128YYwjqscYSoif%2FyLc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AYAAAcUgH%2BCAIKFhoWETIiFIhV%2FhIUDf4EAOw%3D%3D";
  31.  
  32. var ind=new Array("minute","hour","day","week","month","year");
  33. var umr=new Array(1,60,24*60,7*24*60,30*24*60,356*24*60); //just used for friends-list as there only
  34. var watchlist=new Array();
  35. var friendlist=new Array();
  36. var lastactivelist=new Array();
  37. var full=false;
  38. if(GM_getValue("watcher_full")){var full=GM_getValue("watcher_full");}
  39. if(!full&&GM_getValue("watchlist")&&GM_getValue("watchlist")!="none"){watchlist=GM_getValue("watchlist").split(" + ");}
  40. if(!full&&GM_getValue("friendlist")&&GM_getValue("friendlist")!="none"){friendlist=GM_getValue("friendlist").split(" + ");}
  41. var aktwat=false;
  42. var ende=false;
  43. var aktfriend=false;
  44. if(typeof GM_getValue("offbut") == 'undefined'){GM_setValue("offbut","checked");}
  45. if(typeof GM_getValue("watch_display") == 'undefined'){GM_setValue("watch_display","text");}
  46. if(typeof GM_getValue("offakt") == 'undefined'){GM_setValue("offakt",60);}
  47. if(typeof GM_getValue("offletzt") == 'undefined'){GM_setValue("offletzt",0);}
  48. if(typeof GM_getValue("watchlist") == 'undefined'){GM_setValue("watchlist","none");}
  49. if(typeof GM_getValue("friendlist") == 'undefined'){GM_setValue("friendlist","none");GM_setValue("offletzt",0);}
  50. if(typeof GM_getValue("addwatchbut") == 'undefined'){GM_setValue("addwatchbut","");}
  51. if(typeof GM_getValue("hidenotwatch") == 'undefined'){GM_setValue("hidenotwatch","");}
  52.  
  53. if(!GM_getValue || (GM_getValue.toString && GM_getValue.toString().indexOf("not supported")>-1)){
  54. var hint = document.createElement('div');
  55. hint.setAttribute('style',"font:10pt Verdana,Arial,Helvetica,sans-serif!important;background-color:#FFF;left:"+ ((window.innerWidth - 600)/2 - 20) +"px;top:"+ ((window.innerHeight - 150)/2 - 20) +"px;width:600px;height:150px;padding:10px;border:1px double black;position:absolute;z-index:999;");
  56. hint.id="devhint";
  57. hint.innerHTML="You are using Dev_User_inf without a proper Greasemonkey-workaround!<br /><br /> if you are using Chrome, please <b>uninstall the script</b> again and use a script handler like described here: <a href=http://dediggefedde.deviantart.com/journal/44357409/>http://dediggefedde.deviantart.com/journal/44357409/</a> !<br /> If you are using Opera, please use the GM-workaround-scripts like I described here: <a href=http://dediggefedde.deviantart.com/journal/44357409/>http://dediggefedde.deviantart.com/journal/44357409/</a><br /><p style='text-align:center' ><a style='cursor:pointer;' onclick='document.body.removeChild(document.getElementgetElementById(\"devhint\"));'>Close</a></p>";
  58. document.body.appendChild(hint);
  59. return;
  60. }
  61.  
  62. function optionwindow(){
  63. $("#devopts").remove();
  64. var opt = document.createElement('div');
  65. opt.id="devopts";
  66. opt.setAttribute('style',"font:10pt Verdana,Arial,Helvetica,sans-serif!important;background-color:#FFF;left:"+ ((window.innerWidth - 300)/2 - 20) +"px;top:"+ ((window.innerHeight - 250)/2 - 20) +"px;width:300px;height:350px;padding:10px;border:1px double black;position:absolute;z-index:999;");
  67. var ins="";var ins2="";
  68. if(GM_getValue("offbut")){ins=GM_getValue("offbut");}
  69. if(GM_getValue("watch_display")!="text"){ ins2="checked";}
  70. var checkd=new Array("","","","","","");
  71. if(!GM_getValue("offdur")){GM_setValue("offdur",3);}
  72. checkd[parseInt(GM_getValue("offdur"))]="checked";
  73. opt.innerHTML="<h2 align='center'>Options</h2>"+
  74. "<div style='width:150px;padding-bottom:10px;float:left;'>Time untill red status</div>"+
  75. "<div style='width:130px;padding-bottom:10px;padding-right:10px;float:right;'>"+
  76. "<input type='radio' name='dev_time' "+checkd[0]+" value='0'> Minutes<br />"+
  77. "<input type='radio' name='dev_time' "+checkd[1]+" value='1'> Hours<br />"+
  78. "<input type='radio' name='dev_time' "+checkd[2]+" value='2'> Days<br />"+
  79. "<input type='radio' name='dev_time' "+checkd[3]+" value='3'> Weeks<br />"+
  80. "<input type='radio' name='dev_time' "+checkd[4]+" value='4'> Months<br />"+
  81. "<input type='radio' name='dev_time' "+checkd[5]+" value='5'> Years<br />"+
  82. "</div><br style='clear:both;' />"+
  83. "<div style='width:150px;padding-bottom:10px;float:left;'>Duration to update Watch-List</div>"+
  84. "<div style='width:130px;padding-bottom:10px;padding-right:10px;float:right;'><input style='width:40px;' type='text' id='dev_offakt' value='"+GM_getValue('offakt')+"'/> Minutes</div>"+
  85. "</div><br style='clear:both;' />"+
  86. "<div style='width:150px;padding-bottom:10px;float:left;'><label for='dev_addwatchbut'>Extra watch-button!</label></div>"+
  87. "<div style='width:130px;padding-bottom:10px;padding-right:10px;float:right;'><input style='width:40px;' type='checkbox' id='dev_addwatchbut' "+GM_getValue('addwatchbut')+"/></div>"+
  88. "<br style='clear:both;' /><br />"+
  89. "<div style='width:150px;padding-bottom:10px;float:left;'><label for='dev_hidenotwatch'>Hide Not-Watching button!</label></div>"+
  90. "<div style='width:130px;padding-bottom:10px;padding-right:10px;float:right;'><input style='width:40px;' type='checkbox' id='dev_hidenotwatch' "+GM_getValue('hidenotwatch')+"/></div>"+
  91. "<br style='clear:both;' /><br />"+
  92. "<input type='button' value='Save' id='devoptsav' style='margin-left:80px;' />"+
  93. "<input type='button' value='Cancel' id='devoptcan' style='margin-left:30px;' />";
  94. document.body.appendChild(opt);
  95. $("#devoptsav").click(function(){setTimeout(optsav,0);});
  96. $("#devoptcan").click(function(){setTimeout(optcan,0);});
  97. }
  98.  
  99. function optcan(){
  100. $("#devopts").remove();
  101. }
  102.  
  103. function optsav(){
  104. GM_setValue("offdur",$("input[name='dev_time']:checked").val());
  105. if($('#dev_offbut:checked').length!=0){GM_setValue('offbut',"checked");}else{GM_setValue('offbut',"");}
  106. GM_setValue('offakt',$('#dev_offakt').val());
  107. if($('#dev_offdisp:checked').length!=0){GM_setValue("watch_display","image");}else{GM_setValue("watch_display","text");}
  108. GM_setValue('addwatchbut',$("#dev_addwatchbut:checked").length!=0?"checked=\"checked\"":"")
  109. GM_setValue('hidenotwatch',$("#dev_hidenotwatch:checked").length!=0?"checked=\"checked\"":"")
  110. $("#devopts").remove();
  111. }
  112.  
  113. function act(){
  114. if(typeof GM_getValue("offdur") == 'undefined'){GM_setValue("offdur",3);}
  115. var activity=$("#super-secret-activity div.pbox strong").html();
  116. var img="";
  117. var textactivity="";
  118. var sum=0;
  119. for(var x=parseInt(GM_getValue("offdur"));x<6;x++){
  120. sum+=activity.indexOf(ind[x]);
  121. }
  122. if(sum!=-(x-GM_getValue("offdur"))){img=imgoff;textactivity=activity;}else{
  123. if(activity.indexOf("Online")!=-1&&activity.indexOf("<span")==-1){img=imgon;textactivity="online";}else{
  124. if(activity.indexOf("Unknown")!=-1){img=imgunknown;textactivity="invisible";}else{img=imgsemioff;textactivity=activity;}
  125. }
  126. }
  127. fremdusername.after("<img id='dui_act' title='"+textactivity+"' src=\""+img+"\" />");
  128. }
  129.  
  130. function style(){
  131. var style = document.createElement("style");
  132. style.type = "text/css";
  133. style.innerHTML = "#dui_act {padding-bottom: 10px;}"+
  134. ".wart{background-image:url("+imgwarte+")!important;background-position: 0px!important;background-repeat: no-repeat!important;}";
  135. $("head").append(style);
  136. }
  137.  
  138. function changeprofile(name){
  139. if(aktfriend){setTimeout(function(){changeprofile(name)},500);return;}
  140. if(typeof GM_getValue("offbut") == 'undefined'){GM_setValue("offbut","checked");}
  141. var watch=friendlist.indexOf(name.toLowerCase())!=-1;
  142. var watched=watchlist.indexOf(name.toLowerCase())!=-1;
  143. var status=false;
  144. var insert="";
  145. if(watched&&watch){
  146. status=addstat="Mutual Watchers";
  147. color="green";
  148. }else if(watched&&!watch){
  149. status=addstat="Watch back";
  150. color="green";
  151. }else if(!watched&&watch){
  152. status="Watching";
  153. addstat="Not watching you";
  154. color="";
  155. }else if(!watched&&!watch){
  156. status="Watch";
  157. addstat="Not watching you";
  158. color="";
  159. };
  160. if(full){
  161. watchbutton.find("i").removeClass("wart");
  162. }else{
  163. watchbutton.find("i").addClass("wart");
  164. }
  165.  
  166. if(GM_getValue("addwatchbut")=="")
  167. watchbutton.attr("title",status).find("span").html(status);
  168. else{
  169. $("#dev_addwbut").remove();
  170. if(watched||GM_getValue("hidenotwatch")=="")watchbutton.clone(true,true).attr("id","dev_addwbut").attr("class",color+" devwatch gmbutton2 gmbutton2qn2r").insertBefore(watchbutton).find("span").html(addstat);
  171. }
  172. }
  173.  
  174. function getfriends(offset){
  175. aktfriend=true;
  176. if(offset==0)friendlist=new Array();
  177. GM_xmlhttpRequest({
  178. method: 'GET',
  179. url: "http://www.deviantart.com/global/difi.php?c[]=Friends;getFriendsMenu;0,"+offset+"&t=xml&t=json",
  180. // url: "http://www.deviantart.com/global/difi/?c[]=\"Friends\",\"getFriendsList\",[true,\""+offset+"\"]&t=json",
  181. onload: function (responseDetails) {
  182. var resp=eval('(' + responseDetails.responseText + ')');
  183. var currow="";
  184. var i=0;
  185. // while(currow=resp.DiFi.response.calls[0].response.content.Unsorted[i]){
  186. while(currow=resp.DiFi.response.calls[0].response.content.friends[i]){
  187. friendlist.push(currow.username.toLowerCase());
  188. lastactivelist.push(currow.lastvisit);
  189. i++;
  190. }
  191. GM_setValue("friendlist",friendlist.join(" + "));
  192. // if(resp.DiFi.response.calls[0].response.content.Unsorted.length!=0){
  193. if(resp.DiFi.response.calls[0].response.content.friends.length!=0){
  194. getfriends(offset+1);
  195. }else{
  196. aktfriend=false;
  197. }
  198. }
  199. });
  200. }
  201. function getwatched(offset, by, who) {
  202. GM_xmlhttpRequest({
  203. method: 'GET',
  204. url: 'http://'+by+".deviantart.com/modals/watchers/?offset="+offset,
  205. onload: function (responseDetails) {
  206. var rex = /class='u' href='http:\/\/([^\.]*)\.deviantart\.com/gi;
  207. var iter="";
  208. if(responseDetails.responseText.match(rex)==null){
  209. full=true;
  210. GM_setValue("watcher_offset",0);
  211. GM_setValue("watcher_full",true);
  212. GM_setValue("watchlist",watchlist.join(" + "));
  213. if(!GM_getValue("watchlist")){GM_setValue("watchlist","none");}
  214. if(fremdusername.length!=0){
  215. changeprofile(who);
  216. }
  217. }
  218. console.log('http://'+by+".deviantart.com/modals/watchers/?offset="+offset, responseDetails.responseText);
  219. while(iter = rex.exec(responseDetails.responseText)){
  220. watchlist.push(iter[1].toLowerCase());
  221. }
  222. if(!aktwat&&watchlist.indexOf(who.toLowerCase())!=-1){changeprofile(who);aktwat=true;}
  223. if(responseDetails.responseText.search(new RegExp('<a class="disabled">Next</a>',"i"))==-1){
  224. watchbutton.attr("title","analyzing watcher "+offset+"+");
  225. GM_setValue("watcher_offset",offset);
  226. GM_setValue("watchlist",watchlist.join(" + "));
  227. if(!GM_getValue("watchlist")){GM_setValue("watchlist","none");}
  228. getwatched(offset+200, by,who);
  229. }else{
  230. full=true;
  231. GM_setValue("watcher_offset",0);
  232. GM_setValue("watcher_full",true);
  233. GM_setValue("watchlist",watchlist.join(" + "));
  234. if(!GM_getValue("watchlist")){GM_setValue("watchlist","none");}
  235. if(fremdusername.length!=0){
  236. changeprofile(who);
  237. }
  238. }
  239. }
  240. });
  241. }
  242.  
  243. function ladewatchlist(){
  244. if(!full || (parseInt(GM_getValue("offletzt"))+parseInt(GM_getValue("offakt")))<=Math.round(new Date().getTime()/1000/60)){
  245. var offs=0;
  246. if(GM_getValue("watcher_offset")){offs=GM_getValue("watcher_offset");}
  247. full=false;
  248. getfriends(0);
  249. GM_setValue("watcher_full",false);
  250. getwatched(offs,ownusername.html(),fremdusername.html());
  251. // getwatched(offs,"ginkgografix",fremdusername.html());
  252. GM_setValue("offletzt",Math.round(new Date().getTime()/1000/60));
  253. }else{
  254. var tempwatch=GM_getValue("watchlist");
  255. if(typeof tempwatch!="undefined"&&tempwatch!="none"){watchlist=tempwatch.split(" + ");}
  256. var tempwatch=GM_getValue("friendlist");
  257. if(typeof tempwatch!="undefined"&&tempwatch!="none"){friendlist=tempwatch.split(" + ");}
  258. changeprofile(fremdusername.html());
  259. }
  260. }
  261. function pInt(val){
  262. if(typeof val=="undefined")return 0;
  263. return parseInt(val);
  264. }
  265. function highlightlist(){
  266. if(aktfriend)return;
  267. $("table#deviantlist.zebra tr.friend td.l span.a a.username:not([dev_user_inf])").each(function(){
  268. var el=$(this);
  269. setTimeout(function(){
  270. var offdur=3;
  271. if(typeof GM_getValue("offdur") == 'undefined'){GM_setValue("offdur",3);}else{offdur=GM_getValue("offdur");}
  272. var friendid=friendlist.indexOf(el.html().toLowerCase());
  273. var activity=lastactivelist[friendid];
  274. if(friendid==-1){
  275. // GM_log('http://'+el.html().toLowerCase()+".deviantart.com");
  276. // setTimeout(function(){
  277. // $.get( 'http://'+el.html().toLowerCase()+".deviantart.com",function(data){GM_log(data);});
  278. GM_xmlhttpRequest({
  279. method: 'GET',
  280. url: 'http://'+el.html().toLowerCase()+".deviantart.com",
  281. onload: function (responseDetails) {
  282. var resptext=$(responseDetails.responseText).find("#super-secret-activity div.pbox strong").html();
  283. friendlist.push(el.html().toLowerCase());
  284. if(resptext.indexOf("Online")!=-1)lastactivelist.push("Online");else
  285. if(resptext.indexOf("Unknown")!=-1)lastactivelist.push("Invisible");else
  286. if(resptext.indexOf("week")!=-1)lastactivelist.push(resptext.match(/\d+/)+"w");else
  287. if(resptext.indexOf("day")!=-1)lastactivelist.push(resptext.match(/\d+/)+"d");else
  288. if(resptext.indexOf("minute")!=-1)lastactivelist.push(resptext.match(/\d+/)+"m");else
  289. if(resptext.indexOf("hour")!=-1)lastactivelist.push(resptext.match(/\d+/)+"h");else
  290. if(resptext.indexOf("second")!=-1)lastactivelist.push(resptext.match(/\d+/)+"s");else
  291. if(resptext.indexOf("month")!=-1)lastactivelist.push(resptext.match(/\d+/)*7+"w");
  292. // GM_log(responseDetails.responseText);
  293. // GM_log(lastactivelist);
  294. }
  295. });
  296. // },0);
  297. return;
  298. }
  299. el.attr("dev_user_inf",true);
  300. var img="";
  301. var textactivity="";
  302. var sum=0;
  303. var rex=/^(?:(\d+)w)? ?(?:(\d+)d)? ?(?:(\d+)h)? ?(?:(\d+)m)? ?(?:(\d+)s)?$/;
  304. var ex=rex.exec(activity);
  305. if(!ex){
  306. if(activity=="Invisible"){
  307. img=imgunknown;textactivity="Invisible";
  308. }else if(activity=="Online"||activity=="Idle"){
  309. img=imgon;textactivity="Online";
  310. }else{
  311. img=imgoff;textactivity=activity;
  312. }
  313. }else{
  314. var time=new Date();
  315. time.setDate(time.getDate()-pInt(ex[1])*7-pInt(ex[2]));
  316. time.setHours(time.getHours()-pInt(ex[3]));
  317. time.setMinutes(time.getMinutes()-pInt(ex[4]));
  318. time.setSeconds(time.getSeconds()-pInt(ex[5]));
  319. var gtime=new Date();
  320. // var ind=new Array("minute","hour","day","week","month","year");
  321. if(offdur==5)gtime.setMonth(gtime.getMonth()-12);else
  322. if(offdur==4)gtime.setMonth(gtime.getMonth()-1);else
  323. if(offdur==3)gtime.setDate(gtime.getDate()-7);else
  324. if(offdur==2)gtime.setDate(gtime.getDate()-1);else
  325. if(offdur==1)gtime.setHours(gtime.getHours()-1);else
  326. if(offdur==0)gtime.setMinutes(gtime.getMinutes()-1);
  327. textactivity=activity;
  328. if(gtime<=time){
  329. img=imgsemioff;
  330. }else{
  331. img=imgoff;
  332. }
  333. }
  334. el.append("<img id='dui_act' title='"+textactivity+"' src=\""+img+"\" />");
  335. },0);
  336. })
  337. }
  338. if(window.location.href.search("/deviants/")!=-1){
  339. setTimeout(function(){getfriends(0);},0)
  340. highlightlist();
  341. setInterval(highlightlist,1000);
  342. }
  343. if(fremdusername.length!=0){
  344. watchbutton.find("i").addClass("wart");
  345. act();
  346. style();
  347. ladewatchlist();
  348. if(fremdusername.html()==ownusername.html()){
  349. var buttonbar=$("div.gmbutton2town.moarbuttons");
  350. buttonbar.prepend('<a id="dui_watch" class="gmbutton2 gmbutton2qn2r" style="cursor:pointer;" title="dev_user_inf settings"><i class="icon i52"></i><em></em><span>Settings</span><b></b></a>');
  351.  
  352. $("#dui_watch").click(function(){setTimeout(optionwindow,0);});
  353. GM_registerMenuCommand("Dev_User_inf Options", optionwindow,"N","","D");
  354. }
  355. }
  356. })();