Webtoons.com for Desktop

Resizes and downloads higher quality versions of the images on LINE (m.webtoons.com) to improve usability on Desktops and Laptops.

当前为 2014-07-23 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Webtoons.com for Desktop
  3. // @description Resizes and downloads higher quality versions of the images on LINE (m.webtoons.com) to improve usability on Desktops and Laptops.
  4. // @include http://*webtoons.com/viewer?*
  5. // @version 2
  6. // @grant none
  7. // @namespace https://greasyfork.org/users/3807
  8. // ==/UserScript==
  9.  
  10. function main() {
  11. var img = document.createElement("img"),
  12. imgUrl = document.querySelector('._checkVisible').src;
  13. img.src = imgUrl;
  14.  
  15. img.onload = function() {
  16. var heightResizeFactor = img.height / document.querySelector('._checkVisible').height;
  17.  
  18. img.style.visibility = 'hidden';
  19. document.body.appendChild(img);
  20.  
  21. console.log("Detected frame width: " + img.clientWidth + "px");
  22. resizeFrames(img.clientWidth);
  23. resizeViewer(heightResizeFactor);
  24. };
  25. }
  26.  
  27. function resizeFrames(width) {
  28. var imageList = document.querySelectorAll('._checkVisible'),
  29. containerDivs = document.querySelectorAll('.flick-ct'),
  30. imageWidth = width,
  31. containerMargin = (document.body.clientWidth - imageWidth) / 2;
  32. containerMargin = "0px " + containerMargin + "px";
  33.  
  34. for (var i = 0; i < imageList.length; i++) {
  35. var image = imageList[i],
  36. container = containerDivs[i];
  37.  
  38. container.style.width = width + "px";
  39. container.style.margin = containerMargin;
  40. image.src = image.src.replace("?type=q70", "");
  41. }
  42. }
  43.  
  44. function resizeViewer(factor) {
  45. var viewer = document.querySelector('#_viewer'),
  46. height = Number(viewer.style.height.replace('px', '')) * factor;
  47. viewer.style.height = height + "px";
  48. }
  49.  
  50. main();