Thumb Everything

Automatically applies the [thumb] tag to every image in a 3dmm.com post.

目前为 2024-11-20 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Thumb Everything
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3.1
  5. // @description Automatically applies the [thumb] tag to every image in a 3dmm.com post.
  6. // @author Plopilpy
  7. // @match https://*.3dmm.com/*
  8. // @icon https://*.3dmm.com/favicon_3dmmcom_logo.ico
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. var parent, wrapper, i;
  15. var curImg = document.querySelectorAll(`.threedmm_postbit_message img:not(.threedmm_postbit_message .threedmm-thumb img, img.inlineimg)`);
  16. for(i = 0; i < curImg.length;++i){
  17.  
  18. if(curImg[i].getBoundingClientRect().height > 100 && curImg[i].getBoundingClientRect().width > 100){
  19. curImg[i].style.maxWidth = "300px";
  20. curImg[i].style.maxHeight = "300px";
  21.  
  22. parent = curImg[i].parentNode;
  23. wrapper = document.createElement('a');
  24. wrapper.classList.add("threedmm-thumb");
  25. wrapper.href = curImg[i].src;
  26. wrapper.setAttribute("target", "_blank")
  27.  
  28. parent.replaceChild(wrapper, curImg[i]);
  29. wrapper.appendChild(curImg[i]);
  30.  
  31. }
  32. }
  33. })();