Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name My Fancy New Userscript
- // @version 0.1
- // @match http://www.okcupid.com/*
- // @copyright 2012+, Yazdmich
- // ==/UserScript==
- function httpGet(theUrl, callback) {
- var xmlHttp = null;
- xmlHttp = new XMLHttpRequest();
- xmlHttp.open("GET", theUrl, false);
- xmlHttp.send(null);
- return callback(xmlHttp.responseText);
- }
- function insertTooltip(url, element) {
- if (element.hasAttribute('profile') == false) {
- element.setAttribute('profile', null);
- element.profile = httpGet(url.split('?')[0] + '?okc_api=1', JSON.parse);
- }
- var page = element.profile;
- var match = page.matchpercentage;
- var enemy = page.enemypercentage;
- var match2 = Math.round(Math.sqrt(match * (100 - enemy)));
- element.title = '' + match + '%, ' + enemy + '%, ' + match2 + '%';
- console.log(element.title);
- }
- var matches = document.querySelector('#section_matches > ul').getElementsByClassName('match');
- for (index = 0; index < 3; ++index) {
- var current = matches[index].getElementsByClassName('profile_image')[0];
- current.onmouseover = function() {
- insertTooltip(this.href, this)
- };
- }
- for (index = 1; index < 9; ++index) {
- match = document.querySelector('#section_recent > ul > li:nth-child(' + index + ') > a');
- match.onmouseover = function() {
- insertTooltip(this.href, this)
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment