Dev_User_inf

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

目前为 2014-11-27 提交的版本。查看 最新版本

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