Bulgarian whores on Chaturbate

removes ads, shows bulgarian paticipants in selected categories

  1. // ==UserScript==
  2. // @name Bulgarian whores on Chaturbate
  3. // @name:en Bulgarian whores on Chaturbate
  4. // @namespace https://greasyfork.org/en/users/2402-n-tsvetkov
  5. // @version 0.7
  6. // @description removes ads, shows bulgarian paticipants in selected categories
  7. // @description:en removes ads, shows bulgarian paticipants in selected categories
  8. // @author Nikolai Tsvetkov
  9. // @match https://chaturbate.com/
  10. // @grant GM_addStyle
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. const limit = 90; // The limit of items per request
  17. const genders = ['f', 'c']; // Array of gender parameters
  18. const desiredLocation = /bulgaria|sofia|българия|софия|plovdiv|varna|пловдив|варна|бургас|burgas/gi;
  19. const genderIcons = {
  20. s: 'https://web.static.mmcdn.com/images/ico-trans.svg',
  21. f: 'https://web.static.mmcdn.com/images/ico-female.svg',
  22. c: 'https://web.static.mmcdn.com/images/ico-couple.svg',
  23. m: 'https://web.static.mmcdn.com/images/ico-male.svg'
  24. };
  25.  
  26. // Function to fetch initial data to get the total_count for a gender
  27. function fetchInitialData(gender) {
  28. const baseUrl = `https://chaturbate.com/api/ts/roomlist/room-list/?enable_recommendations=true&genders=${gender}&limit=${limit}&offset=0`;
  29. return fetch(baseUrl)
  30. .then(response => response.json())
  31. .then(data => {
  32. return {
  33. gender: gender,
  34. totalCount: data.total_count,
  35. totalPages: Math.ceil(data.total_count / limit),
  36. };
  37. });
  38. }
  39.  
  40. // Function to fetch data for a specific page and gender
  41. function fetchPage(gender, page) {
  42. const offset = page * limit;
  43. const url = `https://chaturbate.com/api/ts/roomlist/room-list/?enable_recommendations=true&genders=${gender}&limit=${limit}&offset=${offset}`;
  44. return fetch(url)
  45. .then(response => response.json())
  46. .then(data => {
  47. return data.rooms;
  48. });
  49. }
  50.  
  51. // Function to filter rooms by desired location
  52. function filterRoomsByLocation(rooms) {
  53. return rooms.filter(room => {
  54. return desiredLocation.test(room.location) || desiredLocation.test(room.country);
  55. });
  56. }
  57.  
  58. // Function to add styles
  59. function addStyles() {
  60. GM_addStyle(".content #bgPlayers{clear: both; float: right; width: 186px; margin: 0 0 0 6px; border: 1px solid #acacac; border-radius: 4px; padding: 5px; min-height: 570px;}");
  61. GM_addStyle("#bgPlayers> div {cursor: pointer}");
  62. }
  63.  
  64. // Function to create the container and append the results
  65. function displayResults(filteredRooms) {
  66. const contentElement = document.querySelector('#main .content');
  67. if (!contentElement) {
  68. console.error('Content element not found');
  69. return;
  70. }
  71.  
  72. const bgPlayers = document.createElement('div');
  73. bgPlayers.id = 'bgPlayers';
  74. contentElement.prepend(bgPlayers);
  75.  
  76. filteredRooms.forEach(room => {
  77. const roomDiv = document.createElement('div');
  78. const iconImg = document.createElement('img');
  79. iconImg.src = genderIcons[room.gender];
  80. iconImg.style.marginRight = '5px';
  81.  
  82. const roomLink = document.createElement('a');
  83. roomLink.href = `https://chaturbate.com/${room.username}/`;
  84. roomLink.target = '_blank';
  85. roomLink.textContent = room.username;
  86.  
  87. roomDiv.appendChild(iconImg);
  88. roomDiv.appendChild(roomLink);
  89. bgPlayers.appendChild(roomDiv);
  90. });
  91. }
  92.  
  93. // Add styles
  94. addStyles();
  95.  
  96. // Fetch initial data for all genders
  97. const initialFetchPromises = genders.map(gender => fetchInitialData(gender));
  98.  
  99. // Wait for all initial fetch requests to complete
  100. Promise.all(initialFetchPromises)
  101. .then(results => {
  102. const fetchPromises = [];
  103.  
  104. // Loop through each result to create fetch promises for each page
  105. results.forEach(result => {
  106. console.log(`Total pages to fetch for gender ${result.gender}: ${result.totalPages}`);
  107. for (let i = 0; i < result.totalPages; i++) {
  108. fetchPromises.push(fetchPage(result.gender, i));
  109. }
  110. });
  111.  
  112. // Wait for all page fetch requests to complete
  113. return Promise.all(fetchPromises);
  114. })
  115. .then(allResults => {
  116. // Flatten the results array and filter rooms by location
  117. const allRooms = allResults.flat();
  118. const filteredRooms = filterRoomsByLocation(allRooms);
  119.  
  120. console.log('Filtered rooms:', filteredRooms);
  121.  
  122. // Display the filtered results
  123. displayResults(filteredRooms);
  124. })
  125. .catch(error => {
  126. console.error('Error fetching data:', error);
  127. });
  128. })();