Pixiv动图预览

在网页右侧显示预览图(非动图适用),分辨率低慎用。

当前为 2017-06-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Pixiv动图预览
  3. // @namespace
  4. // @version 0.2
  5. // @description 在网页右侧显示预览图(非动图适用),分辨率低慎用。
  6. // @author Ocrosoft
  7. // @match https://www.pixiv.net/search.php*
  8. // @match https://www.pixiv.net/member_illust.php*
  9. // @grant none
  10. // @require http://code.jquery.com/jquery-2.1.4.min.js
  11. // ==/UserScript==
  12.  
  13. function addSidePreview() {
  14. 'use strict';
  15. $('._layout-thumbnail').mouseenter(function(){
  16. if($('#preview_div').attr('data-id')==$(this.children[0]).attr('data-id'))return;
  17. //console.log($(this.children[0]).attr('data-id'));
  18. var ifr=document.createElement('iframe');
  19. $(ifr).css({'width':'100%','height':'100%'});
  20. ifr.src='https://www.pixiv.net/member_illust.php?mode=medium&illust_id='+$(this.children[0]).attr('data-id')+'#preview';
  21. $('#preview_div').children().remove();
  22. $('#preview_div').append(ifr);
  23. $('#preview_div').attr('data-id',$(this.children[0]).attr('data-id'));
  24. });
  25. $('._layout-thumbnail').addClass('prev');
  26. }
  27.  
  28. function clearOtherElements(){
  29. if(location.href.indexOf('#preview')==-1)return;
  30. $('body').append($('.works_display')[0]);
  31. $('body').children().each(function(i,d){
  32. if(!$(d).hasClass('works_display'))d.remove();
  33. });
  34. /*var c=$('body').children();
  35. c.each(function(i,d){
  36. if(d.id!='wrapper')d.remove();
  37. else{
  38. $(d).children().each(function(j,e){
  39. if(!$(e).hasClass('layout-a'))e.remove();
  40. else{
  41. $('.layout-column-1').remove();
  42. }
  43. });
  44. }
  45. });
  46. c=$('.layout-column-2').children();
  47. c.each(function(i,d){
  48. if(!$(d).hasClass('_unit'))d.remove();
  49. else{
  50. $(d).children().each(function(j,e){
  51. if(!$(e).hasClass('works_display'))e.remove();
  52. });
  53. }
  54. });*/
  55. //$('body').css('display','');
  56. }
  57.  
  58. if(location.href.indexOf('member_illust.php')!=-1){
  59. //$('body').css('display','none');
  60. $('document').ready(clearOtherElements());
  61. }else {
  62. setInterval(function(){
  63. if($('#preview_div').length<=0){
  64. try{$($('.popular-introduction-block')[0].parentNode).remove();}catch(e){}
  65. var d=document.createElement('div');
  66. d.id="preview_div";
  67. $(d).css({"right":"0px","position":"fixed","top":"0px","width":"25%","height":"100%"});
  68. //d.innerHTML='<iframe style="width:100%;height:100%;"></iframe>';
  69. $('body').append(d);
  70. //https://www.pixiv.net/member_illust.php?mode=medium&illust_id=62814980
  71. }
  72. var t=$('._layout-thumbnail');
  73. if(!$(t[t.length-1]).hasClass('prev'))addSidePreview();
  74. },500);
  75. }