yazdmich

Untitled

Aug 18th, 2014
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name       My Fancy New Userscript
  3. // @namespace  http://use.i.E.your.homepage/
  4. // @version    0.1
  5. // @description  enter something useful
  6. // @match      http://www.okcupid.com/*
  7. // @copyright  2012+, You
  8. // ==/UserScript==
  9. var index;
  10. var urls = [];
  11. var matches = document.querySelector('#section_matches > ul').getElementsByClassName('match');
  12. for (index = 0; index < matches.length; ++index) {
  13.     console.log(matches[index].getElementsByClassName('profile_image')[0].href);
  14.     urls[index]=matches[index].getElementsByClassName('profile_image')[0].href;
  15. }
  16. console.log(urls[0]);
  17. function httpGet(theUrl)
  18. {
  19.     var xmlHttp = null;
  20.  
  21.     xmlHttp = new XMLHttpRequest();
  22.     xmlHttp.open( "GET", theUrl, false );
  23.     xmlHttp.send( null );
  24.     return xmlHttp.responseText;
  25. }
  26. var users = [];
  27. for (index = 0; index < matches.length; ++index) {
  28.         users[index] = httpGet(urls[index]);
  29. }
  30. console.log(users);
  31. var pages = [];
  32. var parser = new DOMParser();
  33. for (index = 0; index < users.length; ++index) {
  34.         pages[index] = parser.parseFromString(users[index], 'text/html');
  35. }
  36. console.log(pages);
  37. var match = [];
  38. var enemy = [];
  39. var match2 = []
  40. for (index = 0; index < pages.length; ++index) {
  41.     match[index] = parseInt(pages[index].querySelector("#percentages > div.percentbox.match > span.percent").innerHTML);
  42.     enemy[index] = parseInt(pages[index].querySelector("#percentages > div.percentbox.enemy > span.percent").innerHTML);
  43.     match2[index] = Math.round(Math.sqrt(match[index]*(100-enemy[index])));
  44. }
  45. console.log(match);
  46. console.log(enemy);
  47. console.log(match2);
  48. for (index = 0; index < matches.length; ++index) {
  49.     document.querySelector('#section_matches > ul').getElementsByClassName('match')[index].getElementsByClassName('profile_image')[0].title=match[index]+'%, '+enemy[index]+'%, '+match2[index]+'%';
  50. }
Advertisement
Add Comment
Please, Sign In to add comment