Advertisement
Guest User

Untitled

a guest
Jun 1st, 2015
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         test
  3. // @namespace    http://your.homepage/
  4. // @version      0.1
  5. // @description  enter something useful
  6. // @author       You
  7. // @match        http://acomics.ru/*/*
  8. // @require      http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  9. // @reauire      https://raw.githubusercontent.com/mrhenry/jquery-image-loader/master/public/jquery-image-loader-min.js
  10. // @grant        none
  11. // ==/UserScript==
  12.  
  13. var nextPage;
  14. var previousPage;
  15. var currentImage;
  16. var currentPage;
  17. var exitPage;
  18. var pageAll;
  19. var comments;
  20.  
  21. $(function(){
  22.     nextPage = $('.next').attr('href');
  23.     currentImage = $('#mainImage').attr('src');
  24.     previousPage = $('.prev').attr('href');
  25.     currentPage = $('.issueNumber').text();
  26.     comments = $('.comment');
  27.     console.log(currentPage);
  28.     $('head').append('<style>'
  29.                      +'.comments\n'
  30.                      +'{position:fixed; top:0px; left:-400px; width:400px; height:100%; border:solid; border-color:#757585; background:white; overflow-y:auto;}\n'
  31.                      +'.comments:hover\n'
  32.                      +'{transition: 0.5s; left:0px;}'
  33.                      +'#download\n'
  34.                      +'{position:absolute; top:50%; left:50%; margin-top: -100px; margin-left: -100px; width:200px; heigth:200px;}'
  35.                      +'</style>');
  36.     var download = $('<div id="download"><img src="http://sierrafire.cr.usgs.gov/images/loading.gif" width="100%" heigth="100%"></img></div>');
  37.     var commentBlock = $('<div></div>').addClass('comments');
  38.     var numberPages = $('<div></div>').css({"position":"fixed", "bottom":"15px","left":"15px","border":"solid","border-color":"#757575","border-radius":"8px","border-width":"2px"}).addClass('pages');
  39.     var exitButton = $("<button>exit</button>").css({"position":"fixed", "bottom":"15px", "right":"15px"});
  40.     var button = $("<button>read</button>").click(function(){
  41.         var imageDiv = $('<div align="center" class="img">').attr('id', 'imageDiv').css({"position":"relative","background-color":"black"});
  42.         var image = $('<img id="dynamic">');
  43.         $('body').html("");
  44.         $('body').append(imageDiv);
  45.         $('body').append(download);
  46.         $('#download').hide();
  47.         image.appendTo('.img');
  48.         numberPages.appendTo('body');
  49.         $('body').on("keydown", function(event){
  50.             if(event.which===39){
  51.                 console.log("button right");
  52.                 getImage(true);
  53.             }
  54.             else if(event.which===37){
  55.                 console.log("button left");
  56.                 getImage(false);
  57.             }
  58.         });
  59.        
  60.         commentBlock.appendTo('body');
  61.         read();
  62.         exitButton.appendTo('body');
  63.     }).css({"position":"fixed", "bottom":"15px", "right":"15px"});
  64.     exitButton.click(function(){
  65.         exit();
  66.     });
  67.     $('body').append(button);
  68.    
  69. });
  70.  
  71. function read(){
  72.     $('body').animate({ scrollTop: 0 }, "fast");
  73.     $('.pages').html('<span>'+currentPage+'</span>');
  74.     $('span').css('color', 'white');
  75.     $('.comments').html(comments);
  76.     $('#dynamic').attr('src', currentImage);
  77.     $('#dynamic').click(function(){
  78.         getImage(true)
  79.     });
  80. }
  81.  
  82. function getImage(next){
  83.     var url;    
  84.     if(next){
  85.         url = nextPage;
  86.         exitPage = nextPage;
  87.     }
  88.     else{
  89.         url = previousPage;
  90.         exitPage = previousPage;
  91.     }
  92.     $('#download').show();
  93.     $.get(url, function(data, status){
  94.         nextPage = $(data).find('.next').attr('href');
  95.         currentImage = $(data).find('#mainImage').attr('src');
  96.         previousPage = $(data).find('.prev').attr('href');
  97.         currentPage = $(data).find('.issueNumber').text();
  98.         comments = $(data).find('.comment');
  99.         data = null;
  100.         read();
  101.         $('#download').hide();
  102.     });
  103. }
  104.  
  105. function exit(){
  106.     window.open(exitPage,"_self");
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement