Sleazy Fork is available in English.

chaturbatefilter

chaturbate-filter

  1. // ==UserScript==
  2. // @name chaturbatefilter
  3. // @version 1.0
  4. // @namespace chaturbate_filter
  5. // @description chaturbate-filter
  6. // @include http://chaturbate.com/*
  7. // @include http://*.chaturbate.com/*
  8. // @grant GM_xmlhttpRequest
  9. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js
  10. // @require http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js
  11. /*
  12. @require https://raw.github.com/jaysalvat/buzz/master/dist/buzz.min.js
  13. */
  14.  
  15. // ==/UserScript==
  16.  
  17. version = 1.0;
  18.  
  19. var pageType = 0;
  20. var startTime = +new Date();
  21.  
  22. var mySound = new buzz.sound( "http://soundjax.com/reddo/21862%5Ebeep1.mp3");
  23. $(function() {
  24. $( "#dialog" ).dialog({
  25. autoOpen: false,
  26. autoResize: true,
  27. height: 'auto',
  28. width: 580,
  29. show: {
  30. effect: "blind",
  31. duration: 100
  32. },
  33. hide: {
  34. duration: 1000
  35. },
  36. position: {
  37. my: 'left',
  38. at: 'center',
  39. of: $('#header')
  40. },
  41. buttons: {
  42. "Close": function() {
  43. $( this ).dialog( "close" );
  44. },
  45. "Clear All": function() {
  46. var targetNodes = $( "#ExhibitionistCams" ).find(".details");
  47. if (targetNodes && targetNodes.length > 0) {
  48. targetNodes.each ( function () {
  49. removeFromAlert(getName($(this)));
  50. } );
  51. }
  52. $( this ).dialog( "close" );
  53. }
  54. },
  55. open: function (event, ui) {
  56. $('#dialog').css('overflow', 'hidden');
  57. }
  58. });
  59. $( "#opener" ).click(function() {
  60. $( "#dialog" ).dialog( "open" );
  61. });
  62. $( "#followeddialog" ).dialog({
  63. autoOpen: false,
  64. autoResize: true,
  65. height: 'auto',
  66. width: 580,
  67. show: {
  68. effect: "blind",
  69. duration: 100
  70. },
  71. hide: {
  72. duration: 1000
  73. },
  74. position: {
  75. my: 'left',
  76. at: 'center',
  77. of: $('#header')
  78. },
  79. buttons: {
  80. "Close": function() {
  81. $( this ).dialog( "close" );
  82. }
  83. },
  84. open: function (event, ui) {
  85. $('#followeddialog').css('overflow', 'hidden');
  86. }
  87. });
  88. $( "#followeddialogopener" ).click(function() {
  89. var targetNodes = $( "#FollowedCams" ).find(".details");
  90. if (targetNodes && targetNodes.length > 0) {
  91. targetNodes.each ( function () {
  92. $( "#FollowedCams" ).find('#'+getName($(this))).remove();
  93. } );
  94. }
  95. $.get( '/followed-cams/', function( data ) {
  96. var dataObj = $('<div/>').html(data);
  97. dataObj.find(".details").each( function() {
  98. var thisCam = createNewUserCam($(this));
  99. if(shouldShowCam(thisCam) && thisCam.type != 3) {
  100. $("#FollowedCams").append(thisCam.cam.parent());
  101. }
  102. });
  103. }).fail(function() {
  104. alert( "error" );
  105. });
  106. $( "#followeddialog" ).dialog( "open" );
  107. });
  108. $( "#report_popupdialog" ).dialog({
  109. autoOpen: false,
  110. autoResize: true,
  111. height: 'auto',
  112. width: 400,
  113. show: {
  114. effect: "blind",
  115. duration: 100
  116. },
  117. hide: {
  118. duration: 1000
  119. },
  120. position: {
  121. my: 'left',
  122. at: 'center',
  123. of: $('#header')
  124. },
  125. buttons: {
  126. "Close": function() {
  127. $( this ).dialog( "close" );
  128. }
  129. },
  130. open: function (event, ui) {
  131. $('#report_popupdialog').css('overflow', 'hidden');
  132. }
  133. });
  134. $( "#report_popupopener" ).click(function() {
  135. logit("report_popupopener clicked");
  136. $("#report_popup form").attr("action", "/abuse/report/lionrauuuhl/");
  137. $( "#report_popupdialog" ).dialog( "open" );
  138. });
  139. });
  140.  
  141. function addCheckboxes() {
  142. var sort, user_informationID = $("#user_information"), logo_zone = $(".logo-zone");
  143. sort =
  144. [
  145. ' <div id="user_information" style="float:right; font-size: 4pt" align="right" >',
  146. ' <div class="top" align="middle">',
  147. ' <label class="username"><strong><font color="#e45900">Sort</font><strong></label>',
  148. ' </div>',
  149. ' <div class="bottom" style="height:40px; padding:0px 4px 4px 0px;">',
  150. ' <table>',
  151. ' <tr height="2px">',
  152. ' <td><label id="showFemaleLabel"><input type="checkbox" name="showFemale" id="showFemale" checked />Show Females</label></td>',
  153. ' <td><label id="showCouplesLabel"><input type="checkbox" name="showCouples" id="showCouples" />Show Couples</label></td>',
  154. ' <td><label id="showOnlyOnlineLabel"><input type="checkbox" name="showOnlyOnline" id="showOnlyOnline" />Show Only Online</label></td>',
  155. ' <td><label id="showOnlyNewLabel"><input type="checkbox" name="showOnlyNew" id="showOnlyNew" />Show Only New</label></td>',
  156. ' <td><label id="showOnly1825Label"><input type="checkbox" name="showOnly1825" id="showOnly1825" />Show 18-25</label></td>',
  157. ' <!--td><button id="followeddialogopener">Followed Cams</button></td-->',
  158. ' </tr>',
  159. ' <tr height="2px">',
  160. ' <td><label id="showMaleLabel"><input type="checkbox" name="showMale" id="showMale" />Show Males</label></td>',
  161. ' <td><label id="showTranssexualLabel"><input type="checkbox" name="showTranssexual" id="showTranssexual" />Show Transsexual</label></td>',
  162. ' <td></td>',
  163. ' <td><label id="showOnlyExhibitionistLabel"><input type="checkbox" name="showOnlyExhibitionist" id="showOnlyExhibitionist" />Show Only Exhibitionist</label></td>',
  164. ' <td><label id="showOnly2635Label"><input type="checkbox" name="showOnly2635" id="showOnly2635" />Show 26-35</label></td>',
  165. ' <!--td><button id="report_popupopener">Report</button></td-->',
  166. ' </tr>',
  167. ' </table>',
  168. ' </div>',
  169. '</div>',
  170. '<div id="dialog" title="New Exhibitionist Cams" >',
  171. ' <div id="ExhibitionistCams" class="list" style="width: 100%; min-width: 0;"></div>',
  172. '</div>',
  173. '<div id="followeddialog" title="Followed Cams" >',
  174. ' <div id="FollowedCams" class="list"></div>',
  175. '</div>',
  176. '<div style="display:none" id="report_popupdialog" title="Report Abuse">',
  177. ' <form method="post" action="">',
  178. ' <div class="report_formborder">',
  179. ' <p class="report_select">Choose a category:',
  180. ' <select name="category" id="id_abuse_category_select">',
  181. ' <option value="">---</option>',
  182. ' <option value="recording">Recorded video</option>',
  183. ' <option value="underage">Broadcaster underage</option>',
  184. ' <option value="advertising">Broadcaster is advertising</option>',
  185. ' <option value="gender">Broadcaster is wrong gender</option>',
  186. ' <option value="other">Other</option>',
  187. ' </select></p>',
  188. ' <p class="report_comments">Additional Comments:<br />',
  189. ' <textarea id="id_additional_comments" name="additional_comments" draggable="false"></textarea>',
  190. ' </p>',
  191. ' <div class="button_abuse_report" style="width: auto;">',
  192. ' <a href="#" class="abuse_report_button" id="abuse_report_button" style="color:#FFF;">REPORT</a>',
  193. ' </div>',
  194. ' <div class="button_abuse_cancel">',
  195. ' <a href="#" class="abuse_cancel_button" id="abuse_cancel_button" style="color:#FFF;">CANCEL</a>',
  196. ' </div>',
  197. ' </div>',
  198. ' </form>',
  199. '</div>',
  200. '<div id="OtherPages"><h2>Cams From Other Pages</h2><div id="OtherPagesInside" class="list"></div></div>',
  201. '<div id="BannedCams"><h2>Banned Cams</h2><div id="BannedCamsInside" class="list"></div></div>',
  202. ].join('\n');
  203. if (typeof user_informationID.html() === "undefined") {
  204. logo_zone.before(sort);
  205. } else {
  206. user_informationID.before(sort);
  207. }
  208. $('#OtherPages').hide();
  209. $('#BannedCams').hide();
  210. $('#showFemale').click(function() {
  211. saveCheckboxSettings();
  212. refreshThePeopleList();
  213. });
  214. $('#showMale').click(function() {
  215. saveCheckboxSettings();
  216. refreshThePeopleList();
  217. });
  218. $('#showCouples').click(function() {
  219. saveCheckboxSettings();
  220. refreshThePeopleList();
  221. });
  222. $('#showTranssexual').click(function() {
  223. saveCheckboxSettings();
  224. refreshThePeopleList();
  225. });
  226. $('#showOnly1825').click(function() {
  227. saveCheckboxSettings();
  228. refreshThePeopleList();
  229. });
  230. $('#showOnlyOnline').click(function() {
  231. saveCheckboxSettings();
  232. refreshThePeopleList();
  233. });
  234. $('#showOnly2635').click(function() {
  235. saveCheckboxSettings();
  236. refreshThePeopleList();
  237. });
  238. $('#showOnlyNew').click(function() {
  239. if($('#showOnlyNew').attr('checked')) {
  240. $('#showOnlyExhibitionist').attr('checked', false);
  241. }
  242. saveCheckboxSettings();
  243. refreshThePeopleList();
  244. });
  245. $('#showOnlyExhibitionist').click(function() {
  246. if($('#showOnlyExhibitionist').attr('checked')) {
  247. $('#showOnlyNew').attr('checked', false);
  248. }
  249. saveCheckboxSettings();
  250. refreshThePeopleList();
  251. });
  252. restoreCheckboxSettings();
  253. }
  254.  
  255. function showHideCheckboxes() {
  256. if (pageType==7) {
  257. toggleCheckbox($('#showOnlyExhibitionist'),$('#showOnlyExhibitionistLabel'),false);
  258. toggleCheckbox($('#showOnlyNew'),$('#showOnlyNewLabel'),false);
  259. } else {
  260. toggleCheckbox($('#showOnlyExhibitionist'),$('#showOnlyExhibitionistLabel'),true);
  261. toggleCheckbox($('#showOnlyNew'),$('#showOnlyNewLabel'),true);
  262. }
  263. if (pageType==2 || pageType==3 || pageType==4 || pageType==5) {
  264. toggleCheckbox($('#showFemale'),$('#showFemaleLabel'),false);
  265. toggleCheckbox($('#showMale'),$('#showMaleLabel'),false);
  266. toggleCheckbox($('#showCouples'),$('#showCouplesLabel'),false);
  267. toggleCheckbox($('#showTranssexual'),$('#showTranssexualLabel'),false);
  268. } else {
  269. toggleCheckbox($('#showFemale'),$('#showFemaleLabel'),true);
  270. toggleCheckbox($('#showMale'),$('#showMaleLabel'),true);
  271. toggleCheckbox($('#showCouples'),$('#showCouplesLabel'),true);
  272. toggleCheckbox($('#showTranssexual'),$('#showTranssexualLabel'),true);
  273. }
  274. if(pageType==6) {
  275. toggleCheckbox($('#showOnlyOnlineLabel'),$('#showOnlyOnline'),true);
  276. } else {
  277. toggleCheckbox($('#showOnlyOnlineLabel'),$('#showOnlyOnline'),false);
  278. }
  279. }
  280.  
  281. function getPageType() {
  282. // 1= Performer Page
  283. // 2= Female Page
  284. // 3= Male Page
  285. // 4= Couple Page
  286. // 5= Transsexual Page
  287. // 6= Followed Page
  288. // 7= Exhibitionist Page
  289. // 0= other
  290. var result = 0, activeTab = $(".active");
  291. if(activeTab.html()!=null) {
  292. if (activeTab.html().indexOf('s Cam') != -1) {
  293. result = 1;
  294. } else if (activeTab.html().indexOf('<a href="/female-cams/">FEMALE</a>') != -1) {
  295. result = 2;
  296. } else if (activeTab.html().indexOf('<a href="/male-cams/">MALE</a>') != -1) {
  297. result = 3;
  298. } else if (activeTab.html().indexOf('<a href="/couple-cams/">COUPLE</a>') != -1) {
  299. result = 4;
  300. } else if (activeTab.html().indexOf('<a href="/transsexual-cams/">TRANSSEXUAL</a>') != -1) {
  301. result = 5;
  302. } else if (activeTab.html().indexOf('<a href="/followed-cams/" class="followed">') != -1) {
  303. result = 6;
  304. } else {
  305. $(".endless_page_template").each(function () {
  306. if ($(this).find(":nth-child(1)").html().indexOf('<h2>Exhibitionist Cams</h2>') != -1) {
  307. result = 7;
  308. }
  309. });
  310. }
  311. }
  312. return result;
  313. }
  314.  
  315. function isBetween18And25(age) {
  316. var ageValues = ["18","19", "20", "21", "22", "23", "24", "25", "99" ];
  317. return ageValues.indexOf(age) > -1;
  318. }
  319.  
  320. function isBetween26And35(age) {
  321. var ageValues = ["26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "99" ];
  322. return ageValues.indexOf(age) > -1;
  323. }
  324.  
  325. function saveCheckboxSettings() {
  326. var checkboxSettings = $(':checkbox').map(function () {return this.checked;}).get().join();
  327. createCookie('checkboxSettings',checkboxSettings);
  328. }
  329.  
  330. function restoreCheckboxSettings() {
  331. var checkboxSettings = readCookie('checkboxSettings');
  332. if(checkboxSettings) {
  333. $(checkboxSettings.split(',')).each(function (i) {
  334. $(':checkbox:eq(' + i + ')').attr('checked', (this.toString() === 'true'));
  335. });
  336. }
  337. }
  338.  
  339. function getAge(jNode) {
  340. var age = "99";
  341. if(jNode.find('.age')) {
  342. age = jNode.find('.age').text();
  343. }
  344. return age;
  345. }
  346.  
  347. function getName(jNode) {
  348. var name = "";
  349. if(jNode.find('.title')) {
  350. name = jNode.find('.title').find('a').text();
  351. }
  352. return name;
  353. }
  354.  
  355. function getGender(jNode) {
  356. // 0=error
  357. // 1=male
  358. // 2=female
  359. // 3=couple
  360. // 4=Transsexual
  361. var result = 0, span = jNode.find('.title span');
  362. if (span && span.hasClass('genderm')) {
  363. result = 1;
  364. } else if (span && span.hasClass('genderf')) {
  365. result = 2;
  366. } else if (span && span.hasClass('genderc')) {
  367. result = 3;
  368. } else if (span && span.hasClass('genders')) {
  369. result = 4;
  370. }
  371. return result;
  372. }
  373.  
  374. function getType(jNode) {
  375. // 0=other
  376. // 1=new
  377. // 2=EXHIBITIONIST
  378. // 3=OFFLINE
  379. // 4=
  380. var result = 0;
  381. if (jNode.parent().html().indexOf('<div class="thumbnail_label thumbnail_label_c_new">NEW</div>') != -1) {
  382. result = 1;
  383. } else if (jNode.parent().html().indexOf('<div class="thumbnail_label thumbnail_label_exhibitionist">EXHIBITIONIST</div>') != -1) {
  384. result = 2;
  385. } else if (jNode.parent().html().indexOf('<div class="thumbnail_label thumbnail_label_offline">OFFLINE</div>') != -1) {
  386. result = 3;
  387. }
  388. return result;
  389. }
  390. function userCam(cam,name,gender,age,type,hidden) {
  391. cam.parent().attr('id',name);
  392. var that= this;
  393. this.cam=cam;
  394. this.name=name;
  395. this.gender=gender;
  396. this.age=age;
  397. this.type=type;
  398. this.hidden=hidden;
  399. this.getGenderString=function() {
  400. var result = "Unknown";
  401. if (that.gender==1) {
  402. result = "Male";
  403. } else if (that.gender==2) {
  404. result = "Female";
  405. } else if (that.gender==3) {
  406. result = "Couple";
  407. } else if (that.gender==4) {
  408. result = "Transsexual";
  409. }
  410. return result;
  411. };
  412. this.href=cam.find('.title a').attr('href');
  413. this.hide=function() {
  414. cam.parent().hide();
  415. hidden=true;
  416. };
  417. this.show=function() {
  418. cam.parent().show();
  419. hidden=false;
  420. };
  421. this.getCamClone=function() {
  422. return cam.parent().clone();
  423. };
  424. var report = '<li id="reportButton"><button id="report_popupopener">Report</button></li>';
  425. //if(this.cam.find('.sub-info #reportButton').length==0)
  426. //this.cam.find('.sub-info .cams').after(report);
  427. }
  428.  
  429. function createNewUserCam(jNode) {
  430. return new userCam(jNode,getName(jNode),getGender(jNode),getAge(jNode),getType(jNode),false);
  431. }
  432.  
  433. function preProcessCam(jNode) {
  434. return createNewUserCam(jNode);
  435. }
  436.  
  437. function shouldShowCam(userCam) {
  438. var result = true;
  439. if (pageType!=2 && pageType!=3 && pageType!=4 && pageType!=5) {
  440. if (userCam.gender==1) {
  441. if(!isChecked($('#showMale'))) {
  442. result = false;
  443. }
  444. } else if (userCam.gender==2) {
  445. if(!isChecked($('#showFemale'))) {
  446. result = false;
  447. }
  448. } else if (userCam.gender==3) {
  449. if(!isChecked($('#showCouples'))) {
  450. result = false;
  451. }
  452. } else if (userCam.gender==4) {
  453. if(!isChecked($('#showTranssexual'))) {
  454. result = false;
  455. }
  456. }
  457. }
  458. if((isChecked($('#showOnlyNew')) && pageType!=7 && userCam.type!=1) || (isChecked($('#showOnlyExhibitionist')) && pageType!=7 && userCam.type!=2)) {
  459. result = false;
  460. }
  461. if (isChecked($('#showOnly1825')) && !isBetween18And25(userCam.age) && !(isChecked($('#showOnly2635')) && !isBetween26And35(userCam.age))) {
  462. result = false;
  463. }
  464. if (isChecked($('#showOnly2635')) && !isBetween26And35(userCam.age) && !(isChecked($('#showOnly1825')) && !isBetween18And25(userCam.age))) {
  465. result = false;
  466. }
  467. if (isChecked($('#showOnlyOnline')) && pageType==7 && userCam.type==3) {
  468. result = false;
  469. }
  470. return result;
  471. }
  472.  
  473. function processCam(userCam) {
  474. if (pageType!=7) {
  475. addTokensRemaining(userCam.cam);
  476. }
  477. if(shouldShowCam(userCam)) {
  478. userCam.show();
  479. } else {
  480. userCam.hide();
  481. }
  482. }
  483.  
  484. function processCams(cams) {
  485. $.each(cams, function (index,userCam) {
  486. processCam(userCam);
  487. });
  488. }
  489.  
  490. var firstTimeThru=true;
  491. function processExhibitionist(userCam, refreshThePeopleListIgnoreUserList) {
  492. if (pageType==7) {
  493. if(refreshThePeopleListIgnoreUserList!==null && !arrayContains(userCam.name, refreshThePeopleListIgnoreUserList.split(',')) && shouldShowCam(userCam)) {
  494. refreshThePeopleListIgnoreUserList = addUserToIgnoreUserList(userCam.name, refreshThePeopleListIgnoreUserList);
  495. var camOnMainPage = false;
  496. $('.list').not("#OtherPagesInside, #BannedCamsInside, #ExhibitionistCams").children("div[id] :visible").each( function() {
  497. //logit(userCam.name);
  498. if($(this).attr('id') == userCam.name) {
  499. camOnMainPage = true;
  500. }
  501. });
  502. if (!firstTimeThru && !camOnMainPage && $("#ExhibitionistCams").find("#"+userCam.name).length == 0 && $("#FollowedCams").find("#"+userCam.name).length == 0) {
  503. var cloneOfCamParent = userCam.getCamClone();
  504. addAlertButtons(cloneOfCamParent, userCam.name);
  505. $("#ExhibitionistCams" ).append(cloneOfCamParent);
  506. var targetNodes = $( "#ExhibitionistCams" ).find(".details");
  507. if (targetNodes && targetNodes.length > 9) {
  508. $('#dialog').dialog('option','width',782);
  509. } else {
  510. $('#dialog').dialog('option','width',580);
  511. }
  512. $("#dialog" ).dialog( "open" );
  513. mySound.play();
  514. setImageRefresh(cloneOfCamParent, userCam.name);
  515. }
  516. }
  517. }
  518. }
  519.  
  520. var refreshThePeopleListRunning = false;
  521. var newUserArray = [];
  522. var currentUserArray = [];
  523. var refreshThePeopleListIgnoreUserList;
  524. function refreshThePeopleList() {
  525. refreshThePeopleListRunning = true;
  526. refreshThePeopleListIgnoreUserList = getUserToIgnoreUserList();
  527. var targetNodes = $(".details");
  528. //$('.list').not("#OtherPagesInside, #BannedCamsInside, #ExhibitionistCams").children(":visible").each( function() {
  529. //});
  530. if (targetNodes && targetNodes.length > 0) {
  531. targetNodes.each ( function () {
  532. var userCam = actionFunction($(this), refreshThePeopleListIgnoreUserList);
  533. newUserArray.push(userCam.name);
  534. });
  535. }
  536. currentUserArray.every(removeRefreshImages);
  537. currentUserArray = newUserArray;
  538. if(newUserArray.length > 0) {
  539. firstTimeThru=false;
  540. }
  541. //might not want to do this
  542. newUserArray = [];
  543. refreshThePeopleListRunning = false;
  544. }
  545.  
  546. function actionFunction(jNode, refreshThePeopleListIgnoreUserList) {
  547. var userCam = preProcessCam(jNode);
  548. processCam(userCam);
  549. processExhibitionist(userCam, refreshThePeopleListIgnoreUserList);
  550. return userCam;
  551. }
  552.  
  553. var intervalMap = new Object();
  554. function setImageRefresh(cloneOfCamParent, name) {
  555. var image = cloneOfCamParent.find('img');
  556. //logit("setImageRefresh for: "+ name);
  557. var thisInterval = setInterval(function (name) {
  558. //logit("Refreshing image for: "+ name);
  559. image[0].src=image[0].src.replace(/\?.*/,function () {
  560. return '?'+new Date();
  561. });
  562. }, 60000);
  563. intervalMap[name] = thisInterval;
  564. }
  565.  
  566. function removeFromAlert(name) {
  567. $( "#ExhibitionistCams" ).find('#'+name).remove();
  568. if ($( "#ExhibitionistCams" ).html() == '') {
  569. $( "#dialog" ).dialog( "close" );
  570. }
  571. }
  572.  
  573. function addAlertButtons(jNode, name) {
  574. jNode.find('.cams').after('<input type="button" id="clearButton_'+name+'" value="Clear" >');
  575. jNode.find('#clearButton_'+name).button().click(function(){ removeFromAlert(name);});
  576. jNode.find('#clearButton_'+name).after('<input type="button" id="removeButton_'+name+'" value="Hide Room Forever" >');
  577. jNode.find('#removeButton_'+name).button().click(function(){ if(window.confirm("Are you sure you want to remove this room from showing on chaturbate forever?")) {alert("Removed");}});
  578. }
  579.  
  580. var removeRefreshImages = function(x) {
  581. var found = false;
  582. for (var i = 0; i < newUserArray.length; i++) {
  583. if(x==newUserArray[i]) {
  584. found = true;
  585. }
  586. }
  587. if(!found && x in intervalMap) {
  588. clearInterval(intervalMap[x]);
  589. delete intervalMap[x];
  590. }
  591. };
  592.  
  593.  
  594.  
  595. function getTokensRemaining(jNode) {
  596. var tokensRemaining = "", subjectElementHTML = jNode.find('.subject').html(),startpos,length;
  597. if(subjectElementHTML && subjectElementHTML.lastIndexOf("[") != -1 && subjectElementHTML.lastIndexOf(" tokens remaining]")!=-1) {
  598. startpos = subjectElementHTML.lastIndexOf("[")+1;
  599. length = subjectElementHTML.lastIndexOf(" tokens remaining]")-startpos;
  600. tokensRemaining = subjectElementHTML.substr(startpos,length);
  601. }
  602. return tokensRemaining.trim();
  603. }
  604.  
  605. function addTokensRemaining(jNode) {
  606. var tokensRemaining = getTokensRemaining(jNode);
  607. if(jNode.find('#tokensRemaining')) {
  608. jNode.find('#tokensRemaining').remove();
  609. }
  610. if(tokensRemaining=="") {
  611. tokensRemaining="--";
  612. }
  613. jNode.find('.cams').after('<li id="tokensRemaining">Tokens Remaining: ['+tokensRemaining+']</li>');
  614. }
  615.  
  616. function addUserToIgnoreUserList(userName, ignoreUserList) {
  617. if (!arrayContains(userName, ignoreUserList.split(','))) {
  618. if (ignoreUserList && ignoreUserList.split(',').length > 0) {
  619. ignoreUserList = ignoreUserList+',';
  620. }
  621. ignoreUserList = ignoreUserList + userName;
  622. createCookie('ignoreUserList',ignoreUserList);
  623. }
  624. return ignoreUserList;
  625. }
  626.  
  627. function getUserToIgnoreUserList() {
  628. var ignoreUserList = readCookie('ignoreUserList');
  629. if(!ignoreUserList) {
  630. ignoreUserList = '';
  631. }
  632. return ignoreUserList;
  633. }
  634. function createCookie(name,value,days) {
  635. var date = new Date(), expires="";
  636. if (days) {
  637. date.setTime(date.getTime()+(days*24*60*60*1000));
  638. expires = "; expires="+date.toGMTString();
  639. }
  640. document.cookie = name+"="+value+expires+"; path=/";
  641. }
  642.  
  643. function readCookie(name) {
  644. var c, i, nameEQ = name + "=", ca = document.cookie.split(';');
  645. for(i=0;i < ca.length;i++) {
  646. c = ca[i];
  647. while (c.charAt(0)==' ') {
  648. c = c.substring(1,c.length);
  649. }
  650. if (c.indexOf(nameEQ) == 0) {
  651. return c.substring(nameEQ.length,c.length);
  652. }
  653. }
  654. return null;
  655. }
  656.  
  657. function eraseCookie(name) {
  658. createCookie(name,"",-1);
  659. }
  660.  
  661. function addGlobalStyle(css) {
  662. var head, style;
  663. head = document.getElementsByTagName('head')[0];
  664. if (!head) { return; }
  665. style = document.createElement('style');
  666. style.type = 'text/css';
  667. style.innerHTML = css;
  668. head.appendChild(style);
  669. }
  670.  
  671. function addStyle(style) {
  672. var head = document.getElementsByTagName("HEAD")[0], ele = head.appendChild(window.document.createElement( 'style' ));
  673. ele.innerHTML = style;
  674. return ele;
  675. }
  676.  
  677. function arrayContains(obj, a) {
  678. var i;
  679. for (i = 0; i < a.length; i++) {
  680. if (a[i] === obj) {
  681. return true;
  682. }
  683. }
  684. return false;
  685. }
  686. function showCheckbox(checkbox, checkboxlabel) {
  687. checkbox.show();
  688. checkboxlabel.show();
  689. }
  690.  
  691. function hideCheckbox(checkbox, checkboxlabel) {
  692. checkbox.hide();
  693. checkboxlabel.hide();
  694. }
  695.  
  696. function checkCheckbox(checkbox,checked) {
  697. if(checked != null) {
  698. checkbox.attr('checked', checked);
  699. }
  700. }
  701.  
  702. function toggleCheckbox(checkbox, checkboxlabel, show, checked) {
  703. if(show) {
  704. showCheckbox(checkbox,checkboxlabel);
  705. } else {
  706. hideCheckbox(checkbox,checkboxlabel);
  707. }
  708. checkCheckbox(checkbox,checked);
  709. }
  710.  
  711. function isChecked(checkbox) {
  712. return checkbox.attr('checked');
  713. }
  714. function loadOtherPagesDiv() {
  715. if (typeof $("#OtherPages2").html() === "undefined") {
  716. var otherPages = $('#OtherPages').clone();
  717. otherPages.attr('id','OtherPages2');
  718. //logit("Showing OtherPages2");
  719. otherPages.show();
  720. var bannedCams = $('#BannedCams').clone();
  721. bannedCams.attr('id','BannedCams2');
  722. //logit("Showing BannedCams2");
  723. bannedCams.show();
  724. // Removes cams that are on this page from otherpagesinside
  725. $.get( window.location.pathname, function( data ) {
  726. $('.list').not("#OtherPagesInside, #BannedCamsInside, #ExhibitionistCams").children(":visible").each( function() {
  727. var thisCamPage = $(this).find('.title a').attr('href');
  728. var thisCamName = thisCamPage.substring(1, thisCamPage.length-1);
  729. if($("#OtherPagesInside").find("#"+thisCamName).length > 0) {
  730. $("#OtherPagesInside").find("#"+thisCamName).remove();
  731. }
  732. });
  733. }).fail(function() {
  734. logit("loadOtherPagesDiv error: " + nextPagelink);
  735. });
  736. $(".content").find('.list').after(otherPages);
  737. $("#OtherPages2").after(bannedCams);
  738. }
  739. }
  740.  
  741. function loadPage(url){
  742. $.get( url, function( data ) {
  743. var dataObj = $('<div/>').html(data);
  744. getCamsFromOtherPages(dataObj);
  745. }).fail(function() {
  746. alert( "error" );
  747. });
  748. }
  749.  
  750. var getCamsFromOtherPagesRunning = false;
  751. function getCamsFromOtherPages() {
  752. getCamsOnPage($("html"));
  753. loadOtherPagesDiv();
  754. }
  755. function getCamsOnPage(data) {
  756. getCamsFromOtherPagesRunning = true;
  757. var nextPagelink = getNextPageLink(data);
  758. if (nextPagelink != null) {
  759. $.get( nextPagelink, function( data ) {
  760. var dataObj = $('<div/>').html(data);
  761. dataObj.find(".details").each( function() {
  762. var thisCam = createNewUserCam($(this));
  763. if(shouldShowCam(thisCam)) {
  764. if ( $("#OtherPagesInside").find("#"+thisCam.name).length == 0) {
  765. $("#OtherPagesInside").append(thisCam.cam.parent());
  766. loadOtherPagesDiv();
  767. } else if ( $("#OtherPagesInside").find("#"+thisCam.name).length == 1) {
  768. var oldCam = $("#OtherPagesInside").find("#"+thisCam.name);
  769. }
  770. }
  771. });
  772. getCamsOnPage(dataObj);
  773. }).fail(function() {
  774. logit("getCamsOnPage error: " + nextPagelink);
  775. });
  776. }
  777. getCamsFromOtherPagesRunning = false;
  778. }
  779.  
  780. //http://chaturbate.com/followed-cams/
  781. //<a href="/followed-cams/" class="followed">FOLLOWED(7/490)</a>
  782. function getFavoritePage(data) {
  783. if($('#followed')) {
  784. getFavoritePage("/followed-cams/");
  785. }
  786. }
  787. function getFavoritePage(nextPagelink) {
  788. if (nextPagelink != null) {
  789. $.get( nextPagelink, function( data ) {
  790. var dataObj = $('<div/>').html(data);
  791. dataObj.find(".details").each( function() {
  792. $("#FavoritePagesInside").append($(this).parent());
  793. });
  794. getFavoritePage(dataObj);
  795. }).fail(function() {
  796. logit("getFavoritePage error: " + nextPagelink);
  797. });
  798. }
  799. }
  800.  
  801. function checkedCam(cam, camPage, lastChecked, status) {
  802. this.cam = cam;
  803. this.camPage = camPage;
  804. this.lastChecked = lastChecked;
  805. this.status = status;
  806. }
  807. var checkedCams = {};
  808. var pauseOtherCams = false;
  809. function checkOtherCamsOnline() {
  810. //logit("\n\n(checkOtherCamsOnline) start");
  811. pauseOtherCams = true;
  812. $("#OtherPagesInside").find('.details').each( function() {
  813. var thisCamPage = $(this).find('.title a').attr('href');
  814. var thisCamName = thisCamPage.substring(1, thisCamPage.length-1);
  815. var thisCam = $("#OtherPagesInside " + "#"+thisCamName);//.find("#"+thisCamName);
  816. //if($(this).find('.thumbnail_label').text() != 'BANNED') {
  817. if(thisCam.find('.thumbnail_label').text() != 'BANNED') {
  818. $.get( thisCamPage, function( data ) {
  819. var status = "Online";
  820. if (data.indexOf("offline_tipping") >= 0) {
  821. status = "Offline";
  822. thisCam.find('.thumbnail_label').attr('class', 'thumbnail_label thumbnail_label_offline');
  823. thisCam.find('.thumbnail_label').text('OFFLINE!');
  824. thisCam.remove();
  825. //logit("(checkOtherCamsOnline) removing: "+thisCamName);
  826. } else if(data.indexOf("This room has been banned.") >= 0) {
  827. status = "Banned";
  828. thisCam.find('.thumbnail_label').attr('class', 'thumbnail_label thumbnail_label_offline');
  829. thisCam.find('.thumbnail_label').text('BANNED');
  830. if ( $("#BannedCamsInside").find("#"+thisCamName).length == 0) {
  831. logit("** Moving Other Page Cam "+thisCamName+"to Banned Cams\n");
  832. thisCam.appendTo("#BannedCamsInside");
  833. } else {
  834. logit("Already in Banned Section, Removing Other Page Cam "+thisCamName + "\n");
  835. thisCam.remove();
  836. }
  837. } else if(data.indexOf("Access Denied. This room is not available to your region or gender.") >= 0) {
  838. status = "Blocked";
  839. thisCam.find('.thumbnail_label').attr('class', 'thumbnail_label thumbnail_label_offline');
  840. thisCam.find('.thumbnail_label').text('BLOCKED');
  841. } else if(data.indexOf("This room requires a password.") >= 0) {
  842. status = "Password";
  843. thisCam.find('.thumbnail_label').attr('class', 'thumbnail_label thumbnail_label_offline');
  844. thisCam.find('.thumbnail_label').text('PASSWORD');
  845. }
  846. if(!(thisCamName in checkedCams)) {
  847. var thisCheckedCam = new checkedCam($(this), thisCamPage, new Date(), status);
  848. checkedCams[thisCamName] = thisCheckedCam;
  849. //logit("Other Pages Cam added: "+ thisCamName);
  850. } else {
  851. var newDate = new Date();
  852. var seconds = (newDate - checkedCams[thisCamName].lastChecked) / 1000;
  853. checkedCams[thisCamName].lastChecked = newDate;
  854. //logit("Other Pages Cam found: "+ thisCamName+", last checked " + seconds +" ago");
  855. }
  856. });
  857. } else {
  858. if ( $("#BannedCamsInside").find("#"+thisCamName).length == 0) {
  859. logit("** Moving Other Page Cam "+thisCamName+"to Banned Cams\n");
  860. thisCam.appendTo("#BannedCamsInside");
  861. } else {
  862. logit("(checkOtherCamsOnline) Already in BannedCamsInside removing: "+thisCamName);
  863. thisCam.remove();
  864. }
  865. }
  866. });
  867. $("#ExhibitionistCams").find('.details').each( function() {
  868. var thisCamPage = $(this).find('.title a').attr('href');
  869. var thisCamName = thisCamPage.substring(1, thisCamPage.length-1);
  870. var thisCam = $("#ExhibitionistCams " + "#"+thisCamName);//.find("#"+thisCamName);
  871. if(thisCam.find('.thumbnail_label').text() != 'BANNED') {
  872. $.get( thisCamPage, function( data ) {
  873. var status = "Online";
  874. if (data.indexOf("offline_tipping") >= 0) {
  875. //logit("(checkOtherCamsOnline) marking as offline in ExhibitionistCams: "+thisCamName);
  876. thisCam.find('.thumbnail_label').attr('class', 'thumbnail_label thumbnail_label_offline');
  877. thisCam.find('.thumbnail_label').text('OFFLINE!');
  878. status = "Offline";
  879. } else if(data.indexOf("This room has been banned.") >= 0) {
  880. logit("(checkOtherCamsOnline) marking as banned in ExhibitionistCams: "+thisCamName);
  881. thisCam.find('.thumbnail_label').attr('class', 'thumbnail_label thumbnail_label_offline');
  882. thisCam.find('.thumbnail_label').text('BANNED');
  883. status = "Banned";
  884. } else if($("#OtherPagesInside").find("#"+thisCamName).length > 0) {
  885. var otherPagesInsideClass = $("#OtherPagesInside").find("#"+thisCamName).find('.thumbnail_label').attr('class');
  886. var otherPagesInsideThumbnail = $("#OtherPagesInside").find("#"+thisCamName).find('.thumbnail_label').text();
  887. //logit("\nthisCamName - Class: "+otherPagesInsideClass+" Thumbnail: "+otherPagesInsideThumbnail+"\n");
  888. thisCam.find('.thumbnail_label').attr('class', otherPagesInsideClass);
  889. thisCam.find('.thumbnail_label').text(otherPagesInsideThumbnail);
  890. } else if(data.indexOf("Access Denied. This room is not available to your region or gender.") >= 0) {
  891. status = "Blocked";
  892. thisCam.find('.thumbnail_label').attr('class', 'thumbnail_label thumbnail_label_offline');
  893. thisCam.find('.thumbnail_label').text('BLOCKED');
  894. } else if(data.indexOf("This room requires a password.") >= 0) {
  895. status = "Password";
  896. thisCam.find('.thumbnail_label').attr('class', 'thumbnail_label thumbnail_label_offline');
  897. thisCam.find('.thumbnail_label').text('PASSWORD');
  898. }
  899. if(!(thisCamName in checkedCams)) {
  900. var thisCheckedCam = new checkedCam($(this), thisCamPage, new Date(), status);
  901. checkedCams[thisCamName] = thisCheckedCam;
  902. //logit("Exhibitionist Cam added: "+ thisCamName);
  903. } else {
  904. var newDate = new Date();
  905. var seconds = (newDate - checkedCams[thisCamName].lastChecked) / 1000;
  906. checkedCams[thisCamName].lastChecked = newDate;
  907. //logit("Exhibitionist Cam found: "+ thisCamName+", last checked " + seconds +" ago");
  908. }
  909. });
  910. } else {
  911. if ( $("#BannedCamsInside").find("#"+thisCamName).length == 0) {
  912. logit("*** Copying Exhibitionist Cam "+thisCamName+" to Banned Cams\n");
  913. var thisCamClone = thisCam.clone();
  914. thisCamClone.find("#clearButton_"+thisCamName).remove();
  915. thisCamClone.find("#removeButton_"+thisCamName).remove();
  916. thisCamClone.appendTo("#BannedCamsInside");
  917. } else {
  918. logit("(checkOtherCamsOnline) Already in BannedCamsInside: "+thisCamName);
  919. }
  920. }
  921. });
  922. var ids = {};
  923. $("#BannedCamsInside").children().each( function() {
  924. logit($(this).attr('id'));
  925. var id = $(this).attr('id');
  926. clearInterval(id);
  927.  
  928. //was this id previously seen?
  929. if ( ids.hasOwnProperty(id) ) {
  930. $( "#"+id ).remove();
  931. }
  932. //a brand new id was discovered!
  933. else {
  934. ids[ id ] = true;
  935. }
  936. });
  937. pauseOtherCams = false;
  938. }
  939.  
  940. function logit(text) {
  941. console.log(text);
  942. }
  943.  
  944. function getNextPageLink(data) {
  945. if(data == null) {
  946. return null;
  947. }
  948. var paging = data.find('.paging'), nextLink = null;
  949. paging.find('link').each(function() {
  950. var rel = $(this).attr('rel');
  951. if(rel=="next") {
  952. nextLink = $(this).attr('href');
  953. }
  954. });
  955. return nextLink;
  956. }
  957.  
  958. $(document).ready(function () {
  959. $(".advanced_search_button").live("click", function () {
  960. $(".advanced_search_button").toggle();
  961. $("a.hide_advanced_search_button").toggle();
  962. $("div.advanced_search_options").slideDown();
  963. return false;
  964. });
  965. $(".hide_advanced_search_button").live("click", function () {
  966. $(".advanced_search_button").toggle();
  967. $("a.hide_advanced_search_button").toggle();
  968. $("div.advanced_search_options").slideUp();
  969. return false;
  970. });
  971. $("#filter_location_form input[type='checkbox']").click(function () {
  972. $(".searching-note").show();
  973. $.ajax({
  974. type: 'POST',
  975. url: $("#filter_location_form").attr("action"),
  976. data: $("#filter_location_form").serialize(),
  977. success: function (data) {
  978. $(".endless_page_template").load(window.location.href);
  979. $(".searching-note").hide();
  980. }
  981. });
  982. return true;
  983. });
  984. $("#filter_options_form").click(function () {
  985. $(".searching-note").show();
  986. $.ajax({
  987. type: 'POST',
  988. url: $("#filter_options_form").attr("action"),
  989. data: $("#filter_options_form").serialize(),
  990. success: function (data) {
  991. $(".endless_page_template").load(window.location.href);
  992. $(".searching-note").hide();
  993. }
  994. });
  995. return true;
  996. });
  997. $("#filter_search_form input[type='submit']").click(function () {
  998. var skey = $("#id_keywords").val();
  999. var search_message = interpolate(gettext("Searching for %(skey)s ..."), {skey: skey}, true);
  1000. $(".searching-keyword h1").text(search_message);
  1001. $(".searching-keyword").show();
  1002. $(".endless_page_template").load($("#filter_search_form").attr("action") + '?' + $("#filter_search_form").serialize());
  1003. return false;
  1004. });
  1005. $('.list').parent().bind("DOMNodeInserted",function(){
  1006. if(!getCamsFromOtherPagesRunning && !refreshThePeopleListRunning && pageType==7) {
  1007. getCamsFromOtherPages();
  1008. refreshThePeopleList();
  1009. } else if(!refreshThePeopleListRunning){
  1010. refreshThePeopleList();
  1011. logit("refreshThePeopleListRunning not running");
  1012. }
  1013. });
  1014. //$('.list').parent().bind("DOMNodeRemoved",function(){
  1015. //console.log('DOMNodeRemoved');
  1016. //});
  1017. });
  1018.  
  1019. function do_script() {
  1020. pageType = getPageType();
  1021. if (pageType!=1) {
  1022. addGlobalStyle('.ui-widget-header-custom {background-color: #3D9700;color:White;font-weight:bold;}');
  1023. addStyle('@import "http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css";');
  1024. addGlobalStyle('.ui-dialog .ui-dialog-buttonpane { text-align: center; }');
  1025. addGlobalStyle('.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { float: none; }');
  1026. if (pageType == 7) {
  1027. createCookie('ignoreUserList','');
  1028. }
  1029. //eraseCookie('ignoreUserList');
  1030. addCheckboxes();
  1031. if (pageType==7) {
  1032. getCamsFromOtherPages();
  1033. }
  1034. refreshThePeopleList();
  1035. showHideCheckboxes();
  1036. setInterval(checkOtherCamsOnline, 30000);
  1037. }
  1038. if (pageType==7) {
  1039. reload_rooms.delay = 10000;
  1040. setTimeout(reload_rooms.on_timeout,15000);
  1041. } else {
  1042. reload_rooms.delay = 90000;
  1043. }
  1044. }
  1045.  
  1046. do_script();
  1047. //.user.js