yazdmich

Untitled

Jun 12th, 2015
562
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://www.okcupid.com/*
  4. // @version      0.1
  5. // @description  enter something useful
  6. // @author       You
  7. // @match        http://www.okcupid.com/*
  8. // @require      http://code.jquery.com/jquery-1.10.2.js
  9. // @require    http://cdnjs.buttflare.com/ajax/libs/toastr.js/latest/js/toastr.js
  10. // @resource   toastr http://cdnjs.buttflare.com/ajax/libs/toastr.js/latest/css/toastr.css
  11. // @grant      GM_addStyle
  12. // @grant      GM_getResourceText
  13. // ==/UserScript==
  14. GM_addStyle(".spinner{-webkit-animation:rotator 1.4s linear infinite;animation:rotator 1.4s linear infinite}@-webkit-keyframes rotator{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(270deg);transform:rotate(270deg)}}@keyframes rotator{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(270deg);transform:rotate(270deg)}}.path{stroke-dasharray:187;stroke-dashoffset:0;-webkit-transform-origin:center;-ms-transform-origin:center;transform-origin:center;-webkit-animation:dash 1.4s ease-in-out infinite,colors 5.6s ease-in-out infinite;animation:dash 1.4s ease-in-out infinite,colors 5.6s ease-in-out infinite}@-webkit-keyframes colors{0%{stroke:#4285F4}25%{stroke:#DE3E35}50%{stroke:#F7C223}75%{stroke:#1B9A59}100%{stroke:#4285F4}}@keyframes colors{0%{stroke:#4285F4}25%{stroke:#DE3E35}50%{stroke:#F7C223}75%{stroke:#1B9A59}100%{stroke:#4285F4}}@-webkit-keyframes dash{0%{stroke-dashoffset:187}50%{stroke-dashoffset:46.75;-webkit-transform:rotate(135deg);transform:rotate(135deg)}100%{stroke-dashoffset:187;-webkit-transform:rotate(450deg);transform:rotate(450deg)}}@keyframes dash{0%{stroke-dashoffset:187}50%{stroke-dashoffset:46.75;-webkit-transform:rotate(135deg);transform:rotate(135deg)}100%{stroke-dashoffset:187;-webkit-transform:rotate(450deg);transform:rotate(450deg)}}#sidebar{position:fixed;background:#f3f5f9;border-radius:3px;padding:8px 5px 5px;margin-left:10px;margin-right:10px}.user{display:inline-block;padding:5px;margin-bottom:-5px;border-radius:3px}h1{font-size:larger}");
  15. var spinner = '<svg class=spinner width=65px height=65px viewBox="0 0 66 66" xmlns=http://www.w3.org/2000/svg><circle class=path fill=none stroke-width=6 stroke-linecap=round cx=33 cy=33 r=30></circle></svg>'
  16. $('#navigation').after($('<div id="sidebar">' + spinner + '</div>'));
  17. var newCSS = GM_getResourceText("toastr");
  18. GM_addStyle(newCSS);
  19. toastr.options = {
  20.     "closeButton": false,
  21.     "debug": false,
  22.     "progressBar": true,
  23.     "positionClass": "toast-bottom-left",
  24.     "showDuration": "10000",
  25.     "hideDuration": "10000",
  26.     "timeOut": "10000",
  27.     "extendedTimeOut": "10000",
  28.     "showEasing": "swing",
  29.     "hideEasing": "linear",
  30.     "showMethod": "fadeIn",
  31.     "hideMethod": "fadeOut"
  32. };
  33. this.$ = this.jQuery = jQuery.noConflict(true);
  34.  
  35. function httpGet(theUrl) {
  36.     console.trace();
  37.     var deferred = $.Deferred();
  38.     var xmlHttp = new XMLHttpRequest();
  39.     xmlHttp.open("GET", theUrl, true);
  40.     xmlHttp.addEventListener('load', function() {
  41.         if (xmlHttp.status === 200) {
  42.             deferred.resolve(xmlHttp.response);
  43.         } else {
  44.             deferred.reject("HTTP error: " + xmlHttp.status);
  45.         }
  46.     }, false);
  47.     xmlHttp.send(null);
  48.     return deferred.promise();
  49. }
  50.  
  51. function insertMatches(url) {
  52.     url = url.split('?')[0] + '?okc_api=1';
  53.     console.log(url)
  54.     var promise = httpGet(url);
  55.     promise.done(function(data) {
  56.         var page = JSON.parse(data);
  57.         var match = page.matchpercentage;
  58.         var enemy = page.enemypercentage;
  59.         var match2 = Math.round(Math.sqrt(match * (100 - enemy)));
  60.         var title = '' + match + '% | ' + enemy + '% | ' + match2 + '%';
  61.         $('#matches').html(title);
  62.         console.log(title);
  63.     });
  64. }
  65. var promise = httpGet('http://www.okcupid.com/visited');
  66. promise.done(function(data) {
  67.     String.prototype.repeat = function(num) {
  68.         return new Array(num + 1).join(this);
  69.     };
  70.     var users = $(data).find('div.user_row_item');
  71.     var userrow = '<div class="row">' + '<div class="user"></div>'.repeat(3) + '</div>';
  72.     var userbox = '<div id="userbox"><hr><center><h1>Mouse over a user above</h1></center></div>'
  73.     $('#sidebar').html('<center><h1>Visited</h1></center>' + userrow.repeat(3) + userbox);
  74.     var grid = $('[class=user]');
  75.     $(users).each(function(index) {
  76.         $(grid[index]).html($(this).find('.username').html().slice(0, -5 - $(this).find('.username > a').html().length) + '<img src=' + $(this).find('.user_image > img').prop('src') + ' width="85" height="85">');
  77.         console.log($(this).find('.name').prop('href'));
  78.         $(grid[index])[0].name = $(this).find('.name').prop('href').slice(31, -11);
  79.         $(grid[index])[0].on('mouseenter', function() {
  80.             $('#userbox > center > h1').html($(this).find('a').html() + '<br>' + this.name + '<br> <div id="matches"><br></div>');
  81.             insertMatches($(this).find('a')[0].href);
  82.         });
  83.     });
  84. });
Advertisement
Add Comment
Please, Sign In to add comment