Advertisement
Guest User

Chaturbate find by country and age

a guest
Jan 27th, 2017
10,574
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.10 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Chaturbate Optimizer
  3. // @description Optimize chaturbate.com, Find models by country and age.
  4. // @include http*://*.chaturbate.com/*
  5. // @include http*://chaturbate.com/*
  6. // @exclude http*://*.chaturbate.com/followed-cams/
  7. // @exclude http*://chaturbate.com/followed-cams
  8. // @updateURL https://searchnmore.000webhostapp.com/cb-findagirl.user.js
  9. // @downloadURL https://searchnmore.000webhostapp.com/cb-findagirl.user.js
  10. // @grant GM_xmlhttpRequest
  11. // @grant GM_addStyle
  12. // @grant GM_getValue
  13. // @grant GM_setValue
  14. // @grant GM_log
  15. // @version 2.9
  16. // ==/UserScript==
  17. document.optimizerVersion = "2.9";
  18.  
  19. //changelog
  20. //Dug out old script from somewhere, fixd it up.
  21. //added filter by country
  22.  
  23. // =============================================================================
  24. // === Global settings =========================================================
  25. // =============================================================================
  26.  
  27. // Additional helper functions
  28. String.prototype.endsWith = function (pSuffix) {
  29. return this.indexOf(pSuffix, this.length - pSuffix.length) !== -1;
  30. };
  31.  
  32. // =============================================================================
  33. // === CSS Styles ==============================================================
  34. // =============================================================================
  35.  
  36. // Overwrite existing styles to make the elements displayed look better and
  37. // nicer
  38. GM_addStyle("#botright { display: none !important; }");
  39. //GM_addStyle("#defchat { width: 1000px !important; }");
  40.  
  41. // Define internal CSS classes for easier access
  42. GM_addStyle(".marvinateButton { font-weight: bold; background-color: #E9E9E9; padding: 6px 8px 4px 8px; margin: 0px 4px 0px 0px; color: #006B94; border: 1px solid #006B94; }");
  43. GM_addStyle(".marvinateButtonActive { background-color: #FFFFFF; }");
  44. GM_addStyle(".marvinateButton:hover { cursor: pointer; text-decoration: none; background-color: #006B94; color: white; } ");
  45. GM_addStyle(".marvinateButtonSmall { display: inline-block; font-weight: bold; background-color: #E9E9E9; padding: 4px 8px 4px 8px; margin: -2px 5px -4px 10px; color: #006B94; border: 1px solid #006B94; }");
  46. GM_addStyle(".marvinateButtonSmall:hover { cursor: pointer; text-decoration: none; background-color: #006B94; color: white; } ");
  47. GM_addStyle(".marvinateSelf { padding: 5px 8px 5px 8px; line-height: 1; position: absolute; left: 280px; top: 8px; border: 1px solid #006B94; font-family: Verdana, Tahoma, Arial, Helvetica; }");
  48. GM_addStyle(".marvinateSelf small { font-size: 10px; }");
  49. GM_addStyle(".marvinateSelfTitle { font-size: 12px; font-weight: bold; color: #000000; }");
  50. GM_addStyle(".marvinatePrefs { width: 500px; margin: 20px auto 0px auto; padding: 10px 15px 10px 15px; border: 5px solid #006B94; background-color: #E9E9E9; }");
  51. GM_addStyle(".marvinatePrefsTitle { font-weight: bold; font-size: 15px; margin: 0px 0px 10px 0px; }");
  52. GM_addStyle(".marvinatePrefsWrapper { position: absolute; left: 0; top: 0; width: 100%; height: 100%; z-index: 9999; }");
  53. GM_addStyle(".marvinatePrefsTable { width: 100%; }");
  54. GM_addStyle(".marvinatePrefsTable td.title { width: 200px; padding: 1px 2px 1px 0px; }");
  55. GM_addStyle(".marvinatePrefsTable td.content { padding: 1px 0px 1px 2px; }");
  56. GM_addStyle(".marvinatePrefsTable td.content input[type=text] { width: 150px; }");
  57. GM_addStyle(".marvinatePrefsButtons { margin: 10px 0px 0px 0px; }");
  58. GM_addStyle(".marvinateDetailInfo { display: inline-block; position: absolute; left: 0; top: 0; z-index: 10; }");
  59. GM_addStyle(".marvinateDetailInfo a { display: block; padding: 8px 4px 8px 4px; font-size: 22px; font-weight: bold; text-decoration: none; border: 1px solid #444444; margin: 5px 0px 0px 5px; }");
  60. GM_addStyle(".marvinateDetailInfoLoading { background-color: #ffffff; opacity: 0.4; color: #000000; }");
  61. GM_addStyle(".marvinateDetailInfoEnabled { background-color: #ff9999; opacity: 0.65; color: #000000; }");
  62. GM_addStyle(".marvinateDetailInfoDisabled { background-color: #99ff99; opacity: 0.4; color: #99ff99; }");
  63.  
  64. // =============================================================================
  65. // === Self identification and header ==========================================
  66. // =============================================================================
  67.  
  68. var logoDiv = MV_getElementByPath("//div[@class='logo-zone']");
  69. if (logoDiv !== null) {
  70.  
  71. var openPreferencesLink = MV_createElement("div", {
  72. "class": "marvinateButtonSmall"
  73. }, "Open Preferences");
  74. openPreferencesLink.addEventListener("click", preferencesOpen, true);
  75.  
  76. var titleLink = MV_createElement("div", {
  77. "class": "marvinateSelfTitle"
  78. });
  79. // titleLink.appendChild(document.createTextNode("Optimizations by marvin - Version " + document.optimizerVersion + " "));
  80. titleLink.appendChild(openPreferencesLink);
  81.  
  82. var authorDiv = MV_createElement("div", {
  83. "class": "marvinateSelf"
  84. });
  85.  
  86. authorDiv.appendChild(titleLink);
  87.  
  88.  
  89. var mycamgirl_completeFunction = function (pElement, pRequest, pResponse) {
  90. var modelhist = pElement.textContent || pElement.innerText;
  91. authorDiv.appendChild(MV_createElement("div", {
  92. "style": "padding: 10px 0px 0px 0px;"
  93. }, "<small>Last Activity:" + modelhist + "</small>"));
  94. };
  95. var mycamgirl_completeFunction2 = function (pElement, pRequest, pResponse) {
  96. var modelhist = pElement.textContent || pElement.innerText;
  97. authorDiv.appendChild(MV_createElement("div", {
  98. "style": "padding: 10px 0px 0px 0px;"
  99. }, "<small>Total:" + modelhist + "</small>"));
  100. };
  101.  
  102. var errorFunction = function (pRequest, pResponse, pException) {
  103.  
  104. };
  105.  
  106. var chatpage = MV_getElementByPath("//*[@id=\"defchat\"]/div[2]");
  107. if (chatpage !== null) {
  108. var currentPageUrl = window.location.href;
  109. var lastSlashIndex = currentPageUrl.lastIndexOf("/");
  110. var currentPageUrl2 = currentPageUrl.substring(0, lastSlashIndex);
  111. lastSlashIndex = currentPageUrl2.lastIndexOf("/");
  112.  
  113. var mycamgirlurl = "http://mycamgirl.net/chaturbate/model" + currentPageUrl.substring(lastSlashIndex);
  114.  
  115. authorDiv.appendChild(MV_createElement("div", {
  116. "style": "padding: 10px 0px 0px 0px;"
  117. }, "<small>mycamgirl:<a href =\"" + mycamgirlurl + "\">" + mycamgirlurl + "</small>"));
  118.  
  119. MV_sendRequest({
  120. url: mycamgirlurl,
  121. xpath: "//*[@id=\"act-1\"]",
  122. onComplete: mycamgirl_completeFunction,
  123. onError: errorFunction
  124. });
  125. MV_sendRequest({
  126. url: mycamgirlurl,
  127. xpath: "//*[@id=\"activity-pct\"]",
  128. onComplete: mycamgirl_completeFunction2,
  129. onError: errorFunction
  130. });
  131. }
  132.  
  133. logoDiv.insertBefore(authorDiv, null);
  134. }
  135.  
  136. // =============================================================================
  137. // === Global :: Utilities =====================================================
  138. // =============================================================================
  139.  
  140. // Replace window.open with a dummy to disable any popups
  141. unsafeWindow.MV_open = unsafeWindow.open;
  142. unsafeWindow.open = function (pUrl, pName, pParameters) {
  143. GM_log("Disabled window.open for URL: " + pUrl);
  144. };
  145.  
  146. // =============================================================================
  147. // === Global :: Preferences ===================================================
  148. // =============================================================================
  149. var country_list = ["russian federation", "London", "united kingdom", "russian", "united states", "europe", "Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Anguilla", "Antigua &amp; Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia &amp; Herzegovina", "Botswana", "Brazil", "British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Cape Verde", "Cayman Islands", "Chad", "Chile", "China", "Colombia", "Congo", "Cook Islands", "Costa Rica", "Cote D Ivoire", "Croatia", "Cruise Ship", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Estonia", "Ethiopia", "Falkland Islands", "Faroe Islands", "Fiji", "Finland", "France", "French Polynesia", "French West Indies", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guam", "Guatemala", "Guernsey", "Guinea", "Guinea Bissau", "Guyana", "Haiti", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kuwait", "Kyrgyz Republic", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macau", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Mauritania", "Mauritius", "Mexico", "Moldova", "Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco", "Mozambique", "Namibia", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Palestine", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Puerto Rico", "Qatar", "Reunion", "Romania", "Russia", "Rwanda", "Saint Pierre &amp; Miquelon", "Samoa", "San Marino", "Satellite", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "South Africa", "South Korea", "Spain", "Sri Lanka", "St Kitts &amp; Nevis", "St Lucia", "St Vincent", "St. Lucia", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Timor L'Este", "Togo", "Tonga", "Trinidad &amp; Tobago", "Tunisia", "Turkey", "Turkmenistan", "Turks &amp; Caicos", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "Uruguay", "Uzbekistan", "Venezuela", "Vietnam", "Virgin Islands (US)", "Yemen", "Zambia", "Zimbabwe"];
  150.  
  151. function preferencesRow(pTitle, pContent) {
  152. var tableRow = MV_createElement("tr");
  153. var titleCell = MV_createElement("td", {
  154. "class": "title"
  155. }, pTitle);
  156. var contentCell = MV_createElement("td", {
  157. "class": "content"
  158. });
  159. contentCell.appendChild(pContent);
  160. tableRow.appendChild(titleCell);
  161. tableRow.appendChild(contentCell);
  162. return tableRow;
  163. }
  164.  
  165. function preferencesOpen() {
  166.  
  167. var preferencesInnerDiv = MV_createElement("div", {
  168. "class": "marvinatePrefs"
  169. });
  170. var preferencesOuterDiv = MV_createElement("div", {
  171. "class": "marvinatePrefsWrapper"
  172. });
  173. preferencesOuterDiv.close = function () {
  174. preferencesOuterDiv.parentNode.removeChild(preferencesOuterDiv);
  175. };
  176. preferencesOuterDiv.appendChild(preferencesInnerDiv);
  177.  
  178. var highlightLanguages = GM_getValue("marvinateHighlightLanguages");
  179. var highlightLanguagesField = MV_createElement("input", {
  180. "type": "text",
  181. "value": highlightLanguages === null ? "" : highlightLanguages
  182. });
  183.  
  184. var hideothersValue = GM_getValue("hideothers") !== false ? true : false;
  185. var hideothersbox = MV_createElement("input", {"type": "checkbox" });
  186. if (hideothersValue !== false) hideothersbox.checked = true;
  187.  
  188.  
  189. var ageMinimumValue = GM_getValue("marvinateAgeMinimum");
  190. var ageMinimumField = MV_createElement("input", {
  191. "type": "text",
  192. "value": ageMinimumValue === null ? "" : ageMinimumValue
  193. });
  194. var ageMaximumValue = GM_getValue("marvinateAgeMaximum");
  195. var ageMaximumField = MV_createElement("input", {
  196. "type": "text",
  197. "value": ageMaximumValue === null ? "" : ageMaximumValue
  198. });
  199.  
  200. var prefsTable = MV_createElement("table", {
  201. "class": "marvinatePrefsTable"
  202. });
  203. prefsTable.appendChild(preferencesRow("Highlight users from countries", highlightLanguagesField));
  204. prefsTable.appendChild(preferencesRow("Hide others", hideothersbox));
  205. prefsTable.appendChild(preferencesRow("Age minimum", ageMinimumField));
  206. prefsTable.appendChild(preferencesRow("Age maximum", ageMaximumField));
  207.  
  208. var saveFunction = function () {
  209. GM_setValue("marvinateHighlightLanguages", highlightLanguagesField.value);
  210. GM_setValue("hideothers", hideothersbox.checked !== false ? hideothersbox.value : false);
  211. GM_setValue("marvinateAgeMinimum", ageMinimumField.value !== null && ageMinimumField.value.length > 1 ? parseInt(ageMinimumField.value.trim()) : "");
  212. GM_setValue("marvinateAgeMaximum", ageMaximumField.value !== null && ageMaximumField.value.length > 1 ? parseInt(ageMaximumField.value.trim()) : "");
  213. //alert("Preferences saved! (Reload the current page to make sure they're applied)");
  214. preferencesOuterDiv.close();
  215. };
  216.  
  217. var prefsButtonArea = MV_createElement("div", {
  218. "class": "marvinatePrefsButtons"
  219. });
  220. prefsButtonArea.appendChild(MV_createButton({
  221. "class": "marvinateButton",
  222. "value": "Save Preferences"
  223. }, saveFunction));
  224. prefsButtonArea.appendChild(MV_createButton({
  225. "class": "marvinateButton",
  226. "value": "Cancel"
  227. }, function () {
  228. preferencesOuterDiv.close();
  229. }));
  230.  
  231. preferencesInnerDiv.appendChild(MV_createElement("div", {
  232. "class": "marvinatePrefsTitle"
  233. }, ""));
  234. preferencesInnerDiv.appendChild(prefsTable);
  235. preferencesInnerDiv.appendChild(prefsButtonArea);
  236. document.body.appendChild(preferencesOuterDiv);
  237.  
  238. }
  239.  
  240.  
  241.  
  242.  
  243. // =============================================================================
  244. // === Cam listings ============================================================
  245. // =============================================================================
  246.  
  247. // Restyle the list element to fit the complete page (normally, on the right
  248. // side there would be place for ads, but since we removed them all, we can
  249. // extend the page to fill the remaining space)
  250. var listElement = MV_getElementByPath("//div[@class='c-1 endless_page_template']");
  251. if (listElement !== null) {
  252. listElement.setAttribute("style", "margin: 0px 0px 0px 15px; padding: 0; z-index: 999;");
  253. }
  254.  
  255. // Add the optimizations to be performed dynamically
  256. var optimizeUserListListeners = [];
  257.  
  258. function optimizeUserList() {
  259. var i = 0;
  260. while (i < optimizeUserListListeners.length) {
  261. optimizeUserListListeners[i]();
  262. i++;
  263. }
  264. }
  265.  
  266. var refreshThePeopleListRunning = false;
  267. // Optimize each of the cells in which a user cam is being displayed.
  268. var profileNodes = document.evaluate("//ul[@class='list']/li", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  269. if (profileNodes !== null && profileNodes.snapshotLength > 0) {
  270.  
  271. // We do not want the site to trigger all timeouts. First of all, no ads
  272. // should be allowed to be reloaded and second of all, the site implements
  273. // a global reload scheduling process, that doesn't take the optimizations
  274. // into account.
  275. // So, what we do here is to replace the default windows setTimeout function
  276. // with a dummy, that does nothing. However, if we ourselves ever want to
  277. // initiate a setTimeout we capture the function itself by making it
  278. // available under the MV_setTimeout key
  279. unsafeWindow.MV_setTimeout = unsafeWindow.setTimeout;
  280. unsafeWindow.setTimeout = function (pFunction) {};
  281.  
  282. optimizeUserListListeners.push(function () {
  283. refreshThePeopleListRunning = true;
  284. profileNodes = document.evaluate("//ul[@class='list']/li", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  285.  
  286. var highlightCountriesPrefsValue = GM_getValue("marvinateHighlightLanguages");
  287. var highlightCountries = highlightCountriesPrefsValue === null ? null : highlightCountriesPrefsValue.split(",");
  288. for (var i = 0; i < profileNodes.snapshotLength; i++) {
  289. var profileNode = profileNodes.snapshotItem(i);
  290.  
  291. var alreadyAltered = profileNode.getAttribute("marvinateAltered");
  292. if (!alreadyAltered) {
  293. profileNode.setAttribute("marvinateAltered", true);
  294.  
  295. // Enhance the list with the information already known from the
  296. // listings page
  297. enhanceUserListingElement(profileNode);
  298.  
  299. var detailPageUrl = "http://" + window.location.hostname + document.evaluate("a", profileNode, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null).snapshotItem(0).getAttribute("href") + "?track=addon28&campaign=gmltV";
  300. var detailLoadingInfoElement = MV_createElement("div", {
  301. "class": "marvinateDetailInfo"
  302. });
  303. var detailLoadingInfoLink = MV_createElement("a", {
  304. "class": "marvinateDetailInfoLoading",
  305. "href": detailPageUrl
  306. }, "?");
  307. detailLoadingInfoElement.appendChild(detailLoadingInfoLink);
  308. document.evaluate("a", profileNode, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null).snapshotItem(0).setAttribute("href", detailPageUrl);
  309.  
  310. profileNode.appendChild(detailLoadingInfoElement);
  311.  
  312. // Now load the detail page and add information only found there
  313. MV_sendRequest({
  314. url: detailPageUrl,
  315. xpath: "//body",
  316. originalProfileNode: profileNode,
  317. originalLoadingInfoElement: detailLoadingInfoLink,
  318. onComplete: function (pElement, pRequest, pResponse) {
  319. enhanceUserListingElementFromDetailPageInformation(pRequest.originalProfileNode, pElement, pRequest.originalLoadingInfoElement);
  320. },
  321. onError: function (pRequest, pResponse, pException) {
  322. // Ignore here - we canot do anything!
  323. }
  324. });
  325.  
  326. }
  327. }
  328. refreshThePeopleListRunning = false;
  329. });
  330. }
  331.  
  332. function enhanceUserListingElement(profileNode) {
  333. profileNode.setAttribute("style", "max-height: 300px");
  334. var linkElement = MV_getElementByPath("a", profileNode);
  335. var ageMinimumValue = GM_getValue("marvinateAgeMinimum");
  336. var ageMinimum = ageMinimumValue === null|| ageMinimumValue == "" ? null : parseInt(ageMinimumValue);
  337. var ageMaximumValue = GM_getValue("marvinateAgeMaximum");
  338. var ageMaximum = ageMaximumValue === null || ageMaximumValue == "" ? null : parseInt(ageMaximumValue);
  339.  
  340. var ageElement = MV_getElementByPath("div[@class='details']//span[contains(@class, 'age')]", profileNode);
  341. var ageElementValue = ageElement === null ? null : ageElement.innerHTML;
  342. var ageInteger = ageElementValue === null|| isNaN(ageElementValue.trim()) ? null : parseInt(ageElementValue.trim());
  343. if (ageInteger != null && ageInteger != Number.NaN && ageMinimum != null || ageMaximum != null) {
  344. var ageValidMinimum = ageMinimum === null|| ageMinimum <= ageInteger;
  345. var ageValidMaximum = ageMaximum === null|| ageMaximum >= ageInteger;
  346. if (!ageValidMinimum || !ageValidMaximum) {
  347. /*
  348. var blockingElement = MV_createElement("a", {
  349. "style" : "display: block; position: absolute; left: 0; top: 0; width: 180px; height: 220px; opacity: 0.75; background-color: #ffffff; z-index: 20; text-decoration: none;"
  350. }, "&nbsp;")
  351. blockingElement.setAttribute("href", linkElement.getAttribute("href"));
  352. profileNode.appendChild(blockingElement);
  353. */
  354. profileNode.setAttribute("style", "display: none;");
  355. }
  356. }
  357.  
  358. // Highlight if country matches
  359. var country_listu = arraytoupper(country_list);
  360. var highlightCountriesPrefsValue = GM_getValue("marvinateHighlightLanguages");
  361. var highlightCountries = highlightCountriesPrefsValue === null ? null : highlightCountriesPrefsValue.split(",");
  362. var highlightCountriesu = arraytoupper(highlightCountries);
  363. var highlightCountryMatchFound = false;
  364.  
  365. var iscountry = true;
  366.  
  367. if (highlightCountries !== null) {
  368. var country = MV_getElementByPath("div[@class='details']//li[contains(@class, 'location')]", profileNode);
  369. country.setAttribute("style", "display: block;");
  370. var countryValue = country === null ? null : country.innerHTML;
  371. var countryarr = countryValue === null ? null : countryValue.split(",");
  372.  
  373. for (var j = 0; j < countryarr.length; j++) {
  374. var countryValue = countryarr[j].trim();
  375.  
  376. console.log(countryValue.toUpperCase().trim());
  377. if (isInArray(countryValue.toUpperCase().trim(), country_listu)) {
  378. var iscountry = true;
  379. if (isInArray(countryValue.toUpperCase().trim(), highlightCountriesu)) {
  380. //for (var j = 0; j < highlightCountries.length && !highlightCountryMatchFound; j++) {
  381.  
  382. //var elementWithLanguage = profileNode//MV_getElementByPath("//dl/dd[contains(text(), '" + highlightCountries[j].trim() + "')]", pDetailPageRoot);
  383. // if (elementWithLanguage != null) {
  384. var highlightCountryMatchFound = true;
  385. profileNode.setAttribute("style", "background-color: #CDD9E5; border: 4px solid green; margin: -3px 4px 4px -3px; border-radius: 2px; ");
  386. // }
  387. }
  388.  
  389. }
  390. }
  391. if (!highlightCountryMatchFound & iscountry & GM_getValue("hideothers") != false ) {
  392. profileNode.setAttribute("style", "display: none;");
  393. }
  394.  
  395. }
  396.  
  397. }
  398.  
  399. function enhanceUserListingElementFromDetailPageInformation(profileNode, pDetailPageRoot, detailInfoElement) {
  400. /// var country_list = ["London","united kingdom","russian","united states","europe","Afghanistan","Albania","Algeria","Andorra","Angola","Anguilla","Antigua &amp; Barbuda","Argentina","Armenia","Aruba","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bermuda","Bhutan","Bolivia","Bosnia &amp; Herzegovina","Botswana","Brazil","British Virgin Islands","Brunei","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Cape Verde","Cayman Islands","Chad","Chile","China","Colombia","Congo","Cook Islands","Costa Rica","Cote D Ivoire","Croatia","Cruise Ship","Cuba","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","Ecuador","Egypt","El Salvador","Equatorial Guinea","Estonia","Ethiopia","Falkland Islands","Faroe Islands","Fiji","Finland","France","French Polynesia","French West Indies","Gabon","Gambia","Georgia","Germany","Ghana","Gibraltar","Greece","Greenland","Grenada","Guam","Guatemala","Guernsey","Guinea","Guinea Bissau","Guyana","Haiti","Honduras","Hong Kong","Hungary","Iceland","India","Indonesia","Iran","Iraq","Ireland","Isle of Man","Israel","Italy","Jamaica","Japan","Jersey","Jordan","Kazakhstan","Kenya","Kuwait","Kyrgyz Republic","Laos","Latvia","Lebanon","Lesotho","Liberia","Libya","Liechtenstein","Lithuania","Luxembourg","Macau","Macedonia","Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Mauritania","Mauritius","Mexico","Moldova","Monaco","Mongolia","Montenegro","Montserrat","Morocco","Mozambique","Namibia","Nepal","Netherlands","Netherlands Antilles","New Caledonia","New Zealand","Nicaragua","Niger","Nigeria","Norway","Oman","Pakistan","Palestine","Panama","Papua New Guinea","Paraguay","Peru","Philippines","Poland","Portugal","Puerto Rico","Qatar","Reunion","Romania","Russia","Rwanda","Saint Pierre &amp; Miquelon","Samoa","San Marino","Satellite","Saudi Arabia","Senegal","Serbia","Seychelles","Sierra Leone","Singapore","Slovakia","Slovenia","South Africa","South Korea","Spain","Sri Lanka","St Kitts &amp; Nevis","St Lucia","St Vincent","St. Lucia","Sudan","Suriname","Swaziland","Sweden","Switzerland","Syria","Taiwan","Tajikistan","Tanzania","Thailand","Timor L'Este","Togo","Tonga","Trinidad &amp; Tobago","Tunisia","Turkey","Turkmenistan","Turks &amp; Caicos","Uganda","Ukraine","United Arab Emirates","United Kingdom","Uruguay","Uzbekistan","Venezuela","Vietnam","Virgin Islands (US)","Yemen","Zambia","Zimbabwe"];
  401. // Highlight if country matches
  402. var country_listu = arraytoupper(country_list);
  403. var highlightCountriesPrefsValue = GM_getValue("marvinateHighlightLanguages");
  404. var highlightCountries = highlightCountriesPrefsValue === null ? null : highlightCountriesPrefsValue.split(",");
  405. var highlightCountriesu = arraytoupper(highlightCountries);
  406. var highlightCountryMatchFound = false;
  407. var iscountry = true;
  408. var profilecountryValue = 0;
  409. if (highlightCountries !== null) {
  410.  
  411.  
  412. for (var j = 0; j < highlightCountries.length && !highlightCountryMatchFound; j++) {
  413.  
  414. var elementWithLanguage = MV_getElementByPath("//dl/dd[contains(text(), '" + highlightCountries[j].trim() + "')]", pDetailPageRoot);
  415. if (elementWithLanguage !== null) {
  416. profilecountryValue = elementWithLanguage === null ? null : elementWithLanguage.innerHTML;
  417. highlightCountryMatchFound = true;
  418. // profileNode.setAttribute("style", "background-color: #CDD9E5; border: 6px solid red; margin: -3px 4px 4px -3px; border-radius: 2px; ");
  419. }
  420. }
  421.  
  422.  
  423. if (highlightCountryMatchFound) {
  424. //console.log(countryValue_str.toUpperCase().trim());
  425. //console.log(profilecountryValue.trim());
  426. profileNode.setAttribute("style", "display: block; background-color: #CDD9E5; border: 6px solid red; margin: -3px 4px 4px -3px; border-radius: 2px;");
  427. }
  428. }
  429.  
  430.  
  431. // Adjust the tipping information
  432. // var tipButtonNode = MV_getElementByPath("//a[@class='tip_button']", pDetailPageRoot);
  433. // detailInfoElement.setAttribute("class", tipButtonNode == null ? "marvinateDetailInfoDisabled" : "marvinateDetailInfoEnabled");
  434. // detailInfoElement.innerHTML = "&#8364;";
  435.  
  436. }
  437.  
  438. function isInArray(value, array) {
  439. return array.indexOf(value) > -1;
  440. }
  441.  
  442. function arraytoupper(array) {
  443. return array.map(function (value) {
  444. return value.toUpperCase();
  445. });
  446. }
  447.  
  448. function createLinkToNextPage(pNextPageNumber) {
  449.  
  450. var nextPageArea = MV_createElement("ul", {
  451. "id": "marvinatePageArea_" + pNextPageNumber,
  452. "class": "list",
  453. "style": "font-weight: bold; "
  454. }, "");
  455. var nextPageLink = MV_createElement("a", {
  456. "id": "marvinatePageLink_" + pNextPageNumber,
  457. "href": "#",
  458. "style": "display: block; border: 1px solid #8BB3DA; margin: 10px 0px 10px 0px; padding: 5px;"
  459. }, "Load next page (page " + pNextPageNumber + ")");
  460. nextPageArea.appendChild(nextPageLink);
  461.  
  462. var appendResultPageFunction = function () {
  463.  
  464. // Show everyone we're busy
  465. var waitingElement = MV_createElement("div", {
  466. "style": "border: 1px solid #8BB3DA; margin: 10px 0px 10px 0px; padding: 5px;"
  467. }, "Loading page " + pNextPageNumber + "...");
  468. nextPageArea.removeChild(nextPageLink);
  469. nextPageArea.appendChild(waitingElement);
  470.  
  471. var completeFunction = function (pElement, pRequest, pResponse) {
  472. nextPageArea.removeChild(waitingElement);
  473. nextPageArea.appendChild(MV_createElement("div", {
  474. "style": "border: 1px solid #8BB3DA; margin: 10px 0px 10px 0px; padding: 5px;"
  475. }, "Page: " + pNextPageNumber));
  476. pagingElement.parentNode.insertBefore(pElement, pagingElement);
  477. optimizeUserList();
  478. createLinkToNextPage(pNextPageNumber + 1);
  479. };
  480.  
  481. var errorFunction = function (pRequest, pResponse, pException) {
  482. nextPageArea.removeChild(waitingElement);
  483. nextPageArea.appendChild(MV_createElement("div", {
  484. "style": "border: 1px solid #8BB3DA; margin: 10px 0px 10px 0px; padding: 5px;"
  485. }, "Cannot load page " + pNextPageNumber + " [" + pException + "]"));
  486. };
  487.  
  488. // Load the next page
  489. var currentPageUrl = window.location.href;
  490. var lastSlashIndex = currentPageUrl.lastIndexOf("/");
  491. var nextPageUrl = currentPageUrl.substring(0, lastSlashIndex + 1) + "?page=" + pNextPageNumber;
  492. MV_sendRequest({
  493. url: nextPageUrl,
  494. xpath: "//ul[@class='list']",
  495. onComplete: completeFunction,
  496. onError: errorFunction
  497. });
  498.  
  499. };
  500.  
  501. nextPageLink.addEventListener("click", appendResultPageFunction, true);
  502. pagingElement.parentNode.insertBefore(nextPageArea, pagingElement);
  503.  
  504. }
  505.  
  506. // Append the next page link
  507. var pagingElement = MV_getElementByPath("//ul[@class='paging']");
  508. if (pagingElement !== null) {
  509.  
  510. optimizeUserListListeners.push(function () {
  511. var activePageLink = MV_getElementByPath("li[@class='active']/a", pagingElement);
  512. if (activePageLink !== null) {
  513. var activePage = parseInt(activePageLink.innerHTML);
  514. createLinkToNextPage(activePage + 1);
  515. }
  516. });
  517.  
  518. optimizeUserListListeners.push(function () {
  519.  
  520. var currentPageUrl = window.location.href;
  521. var currentPageNeedle = "page=";
  522. var currentPageValueStartIndex = currentPageUrl.indexOf(currentPageNeedle);
  523. var currentPageValueEndIndex = currentPageValueStartIndex < 0 ? -1 : currentPageUrl.indexOf("&", currentPageValueStartIndex + 1);
  524. var currentPageValue = currentPageValueStartIndex < 0 ? 1 : parseInt(currentPageUrl.substring(currentPageValueStartIndex + currentPageNeedle.length, currentPageValueEndIndex < 0 ? currentPageUrl.length : currentPageValueEndIndex));
  525.  
  526. var lastSlashIndex = currentPageUrl.lastIndexOf("/");
  527. var nextPageRootUrl = currentPageUrl.substring(0, lastSlashIndex + 1) + "?page=";
  528.  
  529. var newPagingContent = MV_createElement("div");
  530. var appendTargetLinkFunction = function (pPageIndex) {
  531. var classValue = pPageIndex == currentPageValue ? "marvinateButton marvinateButtonActive" : "marvinateButton";
  532. var targetLinkElement = MV_createElement("a", {
  533. "class": classValue,
  534. "style": "margin: 0px 3px 0px 3px; padding: 6px 12px 5px 12px; ",
  535. "href": nextPageRootUrl + pPageIndex
  536. }, pPageIndex);
  537. newPagingContent.appendChild(targetLinkElement);
  538. };
  539. for (var i = 1; i <= currentPageValue + 3; i++) {
  540. appendTargetLinkFunction(i);
  541. }
  542. pagingElement.innerHTML = "";
  543. pagingElement.appendChild(newPagingContent);
  544.  
  545. });
  546.  
  547. }
  548.  
  549. // Run the optimizations (called when the list page is loaded for the first
  550. // time)
  551. optimizeUserList();
  552.  
  553. // =============================================================================
  554. // === Includes ================================================================
  555. // =============================================================================
  556. //
  557. // Include start [domUtil.js]
  558. /*
  559. function MV_removeElementsByPath(pPath) {
  560. var pathResult = document.evaluate(pPath, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  561. if(pathResult.snapshotLength > 0) {
  562. for(var i=0; i < pathResult.snapshotLength; i++) {
  563. var pathNode = pathResult.snapshotItem(i);
  564. pathNode.parentNode.removeChild(pathNode);
  565. }
  566. }
  567. }
  568. */
  569. function MV_getElementByPath(pPath, pRoot) {
  570. var pathResult = document.evaluate(pPath, pRoot === null ? document : pRoot, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  571. return pathResult.snapshotLength <= 0 ? null : pathResult.snapshotItem(0);
  572. }
  573.  
  574. function MV_createButton(pAttributes, pClickListener) {
  575. pAttributes.type = "button";
  576. var resultElement = MV_createElement("input", pAttributes);
  577. if (pClickListener != null) {
  578. resultElement.addEventListener("click", pClickListener, true);
  579. }
  580. return resultElement;
  581. }
  582.  
  583. function MV_createElement(pElementName, pAttributes, pInnerHtml) {
  584. var resultElement = document.createElement(pElementName);
  585. for (var attributeName in pAttributes) {
  586. resultElement.setAttribute(attributeName, pAttributes[attributeName]);
  587. }
  588. if (pInnerHtml != null) {
  589. resultElement.innerHTML = pInnerHtml;
  590. }
  591. return resultElement;
  592. }
  593. // Include end [domUtil.js]
  594. // Include start [xmlhttpUtil.js]
  595. /**
  596. * Sends the request to the remote system and evaluates the response which
  597. * must be valid HTML and contain a specified element identifiable by an XPath
  598. * expression
  599. *
  600. * Expected properties in the request are:
  601. * url
  602. * the URL to which the request will be made
  603. * xpath
  604. * the XPath expression that must evaluate to an element that will be
  605. * extracted from the response received by the remote system
  606. * onComplete
  607. * a function that will be called when the result has been received and the
  608. * content should be displayed
  609. * onError
  610. * a function that will be called if the request cannot be sent or the
  611. * response received is invalid
  612. */
  613. function MV_sendRequest(pRequest) {
  614.  
  615. var processResponse = function (pResponse) {
  616. var responseHtmlStart = pResponse.responseText.indexOf("<html");
  617. var responseHtmlEnd = pResponse.responseText.indexOf("</html>");
  618. if (responseHtmlStart < 0 || responseHtmlEnd < 0) {
  619. pRequest.onError(pRequest, pResponse, "Invalid HTML document received");
  620. } else {
  621. var responseHtmlElement = document.createElement("html");
  622. responseHtmlElement.innerHTML = pResponse.responseText.substring(responseHtmlStart, responseHtmlEnd + "</html>".length);
  623. var responseXpathResult = document.evaluate(pRequest.xpath, responseHtmlElement, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  624. if (responseXpathResult.snapshotLength <= 0) {
  625. pRequest.onError(pRequest, pResponse, "Invalid HTML document received");
  626. } else {
  627. pRequest.onComplete(responseXpathResult.snapshotItem(0), pRequest, pResponse);
  628. }
  629. }
  630. };
  631.  
  632. try {
  633. GM_xmlhttpRequest({
  634. method: "GET",
  635. url: pRequest.url,
  636. onload: processResponse,
  637. onerror: function (pResponse) {
  638. pRequest.onError(pRequest, pResponse, null);
  639. }
  640. });
  641. } catch (e) {
  642. pRequest.onError(pRequest, null, e);
  643. }
  644.  
  645. }
  646. // Include end [xmlhttpUtil.js]
  647. $(document).ready(function () {
  648.  
  649.  
  650. $('.list').parent().bind("DOMNodeInserted", function () {
  651. if (!refreshThePeopleListRunning) {
  652. console.log("refresh");
  653. optimizeUserList();
  654. console.log("refresh done");
  655.  
  656. }
  657.  
  658. });
  659.  
  660. //$('.list').parent().bind("DOMNodeRemoved",function(){
  661. //console.log('DOMNodeRemoved');
  662. //});
  663.  
  664. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement