display the images of tumblr in HD revolution directly for PC and mobile

直接显示电脑版和手机版tumblr的图片为高清版

目前为 2021-08-07 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name display the images of tumblr in HD revolution directly for PC and mobile
  3. // @description 直接显示电脑版和手机版tumblr的图片为高清版
  4. // @version 1.8
  5. // @include http://*.tumblr.com/*
  6. // @include https://*.tumblr.com/*
  7. // @author yechenyin
  8. // @namespace https://greasyfork.org/users/3586-yechenyin
  9. // @require https://code.jquery.com/jquery-1.11.2.min.js
  10. // ==/UserScript==
  11. jQuery.fn.inserted = function(action) {
  12. var selector = this.selector;
  13. if ($(selector).length > 0) {
  14. console.log($(selector).length + ' ' + selector + " is loaded at begin");
  15. action.call($(selector));
  16. }
  17. var reaction = function(records) {
  18. records.map(function(record) {
  19. if (record.target !== document.body && $(record.target).find(selector).length) {
  20. if (record.target.id)
  21. console.log('#' + record.target.id + ' which contains ' + selector + ' is loaded');
  22. else if (record.target.className)
  23. console.log('#' + record.target.className + ' which contains ' + selector + ' is loaded');
  24. else
  25. console.log('#' + record.target.tagName + ' which contains ' + selector + ' is loaded');
  26. //if (trigger_once)
  27. //observer.disconnect();
  28. action.call($(record.target).find(selector));
  29. }
  30. });
  31. };
  32. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  33. if (MutationObserver) {
  34. var observer = new MutationObserver(reaction);
  35. observer.observe(document.body, {
  36. childList: true,
  37. subtree: true
  38. });
  39. } else {
  40. //setInterval(reaction, 100);
  41. }
  42. };
  43. if ($('body').hasClass('is_mobile')) {
  44. $('.mh_post_page').inserted(function() {
  45. $(this).find(".media img").each(function() {
  46. this.src = this.src.replace(/_\d+\./, '_1280.');
  47. });
  48. });
  49. } else {
  50. $(".post_wrapper, .post_container").inserted(function() {
  51. console.log($(this).find(".post_media img").length);
  52. if ($(this).find(".post_media img").length > 0) {
  53. $(this).find(".photoset_photo img").each(function() {
  54. if (this.src != this.parentNode.href)
  55. this.src = this.parentNode.href;
  56. });
  57. $(this).find(".post_media_photo").each(function() {
  58. if ($(this).parent().attr("data-big-photo") && this.src != $(this).parent().attr("data-big-photo")) {
  59. this.src = $(this).parent().attr("data-big-photo");
  60. console.log(this.src);
  61. }
  62. });
  63. }
  64. });
  65. }