Advertisement
erinx

imgur ups&downs

Mar 28th, 2021
450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name Imgur Up/Down Votes
  3. // @namespace erin
  4. // @include *imgur.com/*
  5. // @run-at document-end
  6. // @grant  GM_xmlhttpRequest
  7. // ==/UserScript==
  8.  
  9.  
  10. function imUpDown(){
  11.   var d, db, $;
  12.  
  13.   d = document;
  14.   db = document.body;
  15.  
  16.   $ = function(s, p){
  17.     if(!p || p == null){
  18.       p = db;
  19.     }
  20.     return p.querySelector(s);
  21.   };
  22.  
  23.   $.JSON = function(s){
  24.     if(typeof s == 'string'){
  25.       return JSON.parse(s);
  26.     }else{
  27.       return JSON.stringify(s);
  28.     }
  29.   };
  30.  
  31.   function getUpDown(){
  32.     var pUrl = window.location.href.split('gallery/')[1];
  33.     GM_xmlhttpRequest({
  34.       method: "GET",
  35.       url: "https://api.imgur.com/3/gallery/" + pUrl + "/votes",
  36.       headers: {
  37.         "Authorization": "Client-ID aa85c35462e5c53"
  38.       },
  39.       onload: function(response){
  40.         var rx = $.JSON(response.responseText)['data'];
  41.         $('.post-action-stats-points').innerHTML +=
  42.           '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>▲'
  43.           + rx['ups'] +
  44.           '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;▼'
  45.           + rx['downs'] + '</span>';
  46.       }
  47.     });  
  48.   }
  49.  
  50.   $('.navNext').onclick = function(){
  51.      window.setTimeout(function(){getUpDown();}, 200);
  52.   }
  53.  
  54.   $('.navPrev').onclick = function(){
  55.      window.setTimeout(function(){getUpDown();}, 200);
  56.   }
  57.  
  58.   getUpDown();
  59. }
  60. imUpDown();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement