Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name My Fancy New Userscript
- // @namespace http://use.i.E.your.homepage/
- // @version 0.1
- // @description enter something useful
- // @match http://www.okcupid.com/*
- // @copyright 2012+, You
- // ==/UserScript==
- var index;
- var urls = [];
- var matches = document.querySelector('#section_matches > ul').getElementsByClassName('match');
- for (index = 0; index < matches.length; ++index) {
- console.log(matches[index].getElementsByClassName('profile_image')[0].href);
- urls[index]=matches[index].getElementsByClassName('profile_image')[0].href;
- }
- console.log(urls[0]);
- function httpGet(theUrl)
- {
- var xmlHttp = null;
- xmlHttp = new XMLHttpRequest();
- xmlHttp.open( "GET", theUrl, false );
- xmlHttp.send( null );
- return xmlHttp.responseText;
- }
- var users = [];
- for (index = 0; index < matches.length; ++index) {
- users[index] = httpGet(urls[index]);
- }
- console.log(users);
- var pages = [];
- var parser = new DOMParser();
- for (index = 0; index < users.length; ++index) {
- pages[index] = parser.parseFromString(users[index], 'text/html');
- }
- console.log(pages);
- var match = [];
- var enemy = [];
- var match2 = []
- for (index = 0; index < pages.length; ++index) {
- match[index] = parseInt(pages[index].querySelector("#percentages > div.percentbox.match > span.percent").innerHTML);
- enemy[index] = parseInt(pages[index].querySelector("#percentages > div.percentbox.enemy > span.percent").innerHTML);
- match2[index] = Math.round(Math.sqrt(match[index]*(100-enemy[index])));
- }
- console.log(match);
- console.log(enemy);
- console.log(match2);
- for (index = 0; index < matches.length; ++index) {
- document.querySelector('#section_matches > ul').getElementsByClassName('match')[index].getElementsByClassName('profile_image')[0].title=match[index]+'%, '+enemy[index]+'%, '+match2[index]+'%';
- }
Advertisement
Add Comment
Please, Sign In to add comment