FifiTheBulldog

The Far Side Scriptable attempt

Dec 11th, 2021 (edited)
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const wv = new WebView()
  2. await wv.evaluateJavaScript(`console.info = console.log = () => {};
  3. completion()`, true)
  4. await wv.loadURL("https://thefarside.com")
  5. const imgBase64 = await wv.evaluateJavaScript(`
  6.   const img = document.getElementsByClassName("js-comic")[0].getElementsByClassName("img-fluid")[0];
  7.   img.setAttribute("crossOrigin", "anonymous");
  8.   const c = document.createElement("canvas");
  9.   c.width = Number(img.getAttribute("data-width"));
  10.   c.height = Number(img.getAttribute("data-height"));
  11.   const ctx = c.getContext("2d");
  12.   ctx.globalAlpha = 1;
  13.   ctx.drawImage(img, 0, 0, c.width, c.height);
  14.   completion(c.toDataURL("image/png").split(",")[1]);
  15. `, true);
  16. const img = Image.fromData(Data.fromBase64String(imgBase64));
  17. QuickLook.present(img, false);
Add Comment
Please, Sign In to add comment