yazdmich

Untitled

Oct 29th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name       My Fancy New Userscript
  3. // @version    0.1
  4. // @match      http://www.okcupid.com/*
  5. // @copyright  2012+, Yazdmich
  6. // ==/UserScript==
  7. function httpGet(theUrl, callback) {
  8.     var xmlHttp = null;
  9.     xmlHttp = new XMLHttpRequest();
  10.     xmlHttp.open("GET", theUrl, false);
  11.     xmlHttp.send(null);
  12.     return callback(xmlHttp.responseText);
  13. }
  14.  
  15. function insertTooltip(url, element) {
  16.     if (element.hasAttribute('profile') == false) {
  17.         element.setAttribute('profile', null);
  18.         element.profile = httpGet(url.split('?')[0] + '?okc_api=1', JSON.parse);
  19.     }
  20.     var page = element.profile;
  21.     var match = page.matchpercentage;
  22.     var enemy = page.enemypercentage;
  23.     var match2 = Math.round(Math.sqrt(match * (100 - enemy)));
  24.     element.title = '' + match + '%, ' + enemy + '%, ' + match2 + '%';
  25.     console.log(element.title);
  26. }
  27. var matches = document.querySelector('#section_matches > ul').getElementsByClassName('match');
  28. for (index = 0; index < 3; ++index) {
  29.     var current = matches[index].getElementsByClassName('profile_image')[0];
  30.     current.onmouseover = function() {
  31.         insertTooltip(this.href, this)
  32.     };
  33. }
  34. for (index = 1; index < 9; ++index) {
  35.     match = document.querySelector('#section_recent > ul > li:nth-child(' + index + ') > a');
  36.     match.onmouseover = function() {
  37.         insertTooltip(this.href, this)
  38.     };
  39. }
Advertisement
Add Comment
Please, Sign In to add comment