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.

  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. // @author Gendalph
  5. // @namespace https://greasyfork.org/users/3807
  6. // @include http://*webtoons.com/viewer?*
  7. // @version 2
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. function main() {
  13. var img = document.createElement("img"),
  14. imgUrl = document.querySelector('._checkVisible').src;
  15. img.src = imgUrl;
  16.  
  17. img.onload = function() {
  18. var heightResizeFactor = img.height / document.querySelector('._checkVisible').height;
  19.  
  20. img.style.visibility = 'hidden';
  21. document.body.appendChild(img);
  22.  
  23. console.log("Detected frame width: " + img.clientWidth + "px");
  24. resizeFrames(img.clientWidth);
  25. resizeViewer(heightResizeFactor);
  26. };
  27. }
  28.  
  29. function resizeFrames(width) {
  30. var imageList = document.querySelectorAll('._checkVisible'),
  31. containerDivs = document.querySelectorAll('.flick-ct'),
  32. imageWidth = width,
  33. containerMargin = (document.body.clientWidth - imageWidth) / 2;
  34. containerMargin = "0px " + containerMargin + "px";
  35.  
  36. for (var i = 0; i < imageList.length; i++) {
  37. var image = imageList[i],
  38. container = containerDivs[i];
  39.  
  40. container.style.width = width + "px";
  41. container.style.margin = containerMargin;
  42. image.src = image.src.replace("?type=q70", "");
  43. }
  44. }
  45.  
  46. function resizeViewer(factor) {
  47. var viewer = document.querySelector('#_viewer'),
  48. height = Number(viewer.style.height.replace('px', '')) * factor;
  49. viewer.style.height = height + "px";
  50. }
  51.  
  52. main();