Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Imgur Up/Down Votes
- // @namespace erin
- // @include *imgur.com/*
- // @run-at document-end
- // @grant GM_xmlhttpRequest
- // ==/UserScript==
- function imUpDown(){
- var d, db, $;
- d = document;
- db = document.body;
- $ = function(s, p){
- if(!p || p == null){
- p = db;
- }
- return p.querySelector(s);
- };
- $.JSON = function(s){
- if(typeof s == 'string'){
- return JSON.parse(s);
- }else{
- return JSON.stringify(s);
- }
- };
- function getUpDown(){
- var pUrl = window.location.href.split('gallery/')[1];
- GM_xmlhttpRequest({
- method: "GET",
- url: "https://api.imgur.com/3/gallery/" + pUrl + "/votes",
- headers: {
- "Authorization": "Client-ID aa85c35462e5c53"
- },
- onload: function(response){
- var rx = $.JSON(response.responseText)['data'];
- $('.post-action-stats-points').innerHTML +=
- ' <span>▲'
- + rx['ups'] +
- ' ▼'
- + rx['downs'] + '</span>';
- }
- });
- }
- $('.navNext').onclick = function(){
- window.setTimeout(function(){getUpDown();}, 200);
- }
- $('.navPrev').onclick = function(){
- window.setTimeout(function(){getUpDown();}, 200);
- }
- getUpDown();
- }
- imUpDown();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement