Sleazy Fork is available in English.

Scale Sankaku Beta

Resizes pics on Sankaku beta to full window size when you touch the left side of the window with your cursor. Uses the Magic Kernel Sharp algorithm for scaling.

  1. // ==UserScript==
  2. // @name Scale Sankaku Beta
  3. // @version 0.1.3
  4. // @description Resizes pics on Sankaku beta to full window size when you touch the left side of the window with your cursor. Uses the Magic Kernel Sharp algorithm for scaling.
  5. // @author Octopus Hugger
  6. // @icon https://s2.googleusercontent.com/s2/favicons?domain=https://beta.sankakucomplex.com/
  7. // @grant GM_xmlhttpRequest
  8. // @connect *
  9. // @match *://beta.sankakucomplex.com/*
  10. // @license WTFPL
  11. // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js
  12. // @require https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js
  13. // @require https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/js/bootstrap.min.js
  14. // @require https://cdnjs.cloudflare.com/ajax/libs/lie/3.1.1/lie.min.js
  15. // @require https://cdnjs.cloudflare.com/ajax/libs/pica/9.0.1/pica.min.js
  16. // @namespace https://greasyfork.org/users/879890
  17. // ==/UserScript==
  18.  
  19. // Changelog
  20.  
  21. // 0.1.3
  22. // Improved text readout.
  23.  
  24. // 0.1.2
  25. // Updated description and changelog and decreased rate of checking for Imagus.
  26.  
  27. // 0.1.1
  28. // Fixed issue where the feature to always load original after it's been loaded at least once sometimes didn't work.
  29.  
  30.  
  31. (function() {
  32. 'use strict';
  33. if (window.top != window.self){ //-- Don't run on frames or iframes
  34. return;
  35. }
  36.  
  37. function sleep(ms) {
  38. return new Promise(resolve => setTimeout(resolve, ms));
  39. }
  40.  
  41. function base64img(i){
  42. let canvas = document.createElement('canvas');
  43. canvas.width = i.width;
  44. canvas.height = i.height;
  45. let context = canvas.getContext("2d");
  46. context.drawImage(i, 0, 0);
  47. let blob = canvas.toDataURL("image/png");
  48. return blob;
  49. }
  50.  
  51. function ImgToCanvas(i){
  52. let canvas = document.createElement('canvas');
  53. canvas.width = i.width;
  54. canvas.height = i.height;
  55. let context = canvas.getContext("2d");
  56. context.drawImage(i, 0, 0);
  57. return canvas;
  58. }
  59.  
  60. let resizer;
  61.  
  62.  
  63. let resizer_mode = {
  64. js: true,
  65. wasm: true,
  66. cib: false,
  67. ww: true
  68. };
  69.  
  70. function create_resizer() {
  71. let opts = [];
  72.  
  73. Object.keys(resizer_mode).forEach(function (k) {
  74. if (resizer_mode[k]) opts.push(k);
  75. });
  76.  
  77. resizer = window.pica({ features: opts });
  78. }
  79.  
  80. create_resizer();
  81.  
  82. let cancelactiveresizes;
  83. let cancelresize = new Promise((_, reject) => cancelactiveresizes = reject);
  84.  
  85. let currentpic = "null?"
  86.  
  87. let maindiv = null
  88.  
  89. let savedwidth = null
  90.  
  91. let imagestore = {}
  92.  
  93. let mainimg = null
  94. let towindowsize = false
  95. let mydiv = null
  96. let imgfirstload = true
  97.  
  98. let purgewaittime = 15000
  99.  
  100. function purgeimage(linkvar){
  101. if (currentpic !== linkvar&&linkvar!=inprogress){
  102. delete imagestore[linkvar]
  103. }
  104. else{
  105. imagestore[linkvar+"myexpire"] = setTimeout(purgeimage,purgewaittime,linkvar)
  106. }
  107. }
  108.  
  109. function getSankImageType(linkvar){
  110. if(linkvar==null||linkvar==undefined) return null
  111. if(linkvar.search("preview")!==-1){
  112. return "Thumbnail"
  113. }
  114. else if(linkvar.search("sample")!==-1){
  115. return "Sample"
  116. }
  117. else {
  118. return "Original"
  119. }
  120. }
  121.  
  122. let imagereadoutcount = 0
  123. let readoutlinkvar=null
  124. function imagereadout(inputtext,w,linkvar,editnumber){
  125. if(linkvar!==null&&linkvar!==undefined&&linkvar!=="null?"){
  126. if(readoutlinkvar!==null&&linkvar!==readoutlinkvar){
  127. return
  128. }
  129. if(inputtext=="Waiting for server"&&getSankImageType(linkvar)=="Original") return
  130. }
  131. if(imagereadoutcount>=50&&inputtext!=="Scaling Complete"){
  132. clearimagereadout()
  133. if(linkvar.search("sankakucomplex.com")!==-1){
  134. imagereadout(getSankImageType(linkvar),w,linkvar)
  135. }
  136. }
  137. let currentreadout
  138. if(editnumber!==undefined&&editnumber!==null){
  139. currentreadout = imagereadoutcount
  140. }
  141. else{
  142. imagereadoutcount+=1
  143. currentreadout = imagereadoutcount
  144. }
  145. let readouttext = document.createElement("readouttext"+currentreadout)
  146. readouttext.id = "readouttext"+currentreadout
  147.  
  148. readouttext.style.pointerEvents="none"
  149. readouttext.style.backgroundColor="black"
  150. readouttext.style["border-color"]="black"
  151. if(inputtext=="Original") {
  152. readouttext.style.backgroundColor="#F70DFF"
  153. readouttext.style["border-color"]="#F70DFF"
  154. }
  155. else if(inputtext=="Sample") {
  156. readouttext.style.backgroundColor="#1C37FF"
  157. readouttext.style["border-color"]="#1C37FF"
  158. }
  159. else if(inputtext=="Thumbnail") {
  160. readouttext.style.backgroundColor="#FF0000"
  161. readouttext.style["border-color"]="#FF0000"
  162. }
  163. readouttext.style.color="white"
  164. readouttext.style["border-style"]="solid"
  165. readouttext.innerText=inputtext
  166.  
  167.  
  168. if(document.getElementById('readouttext'+currentreadout) !== null){
  169. document.getElementById('mydiv').replaceChild(readouttext,document.getElementById('readouttext'+currentreadout))
  170. }
  171. else{
  172. document.getElementById('mydiv').appendChild(readouttext)
  173. }
  174.  
  175. if(w==window.innerWidth||imagereadoutcount>1&&document.getElementById('readouttext'+(imagereadoutcount-1)).offsetLeft>=0){
  176. if(imagereadoutcount>1&&document.getElementById('readouttext'+(imagereadoutcount-1)).offsetLeft<0){
  177. for(let i=1;i<imagereadoutcount;i++){
  178. document.getElementById('readouttext'+i).style.position="relative"
  179. document.getElementById('readouttext'+i).style.top="-20px"
  180. document.getElementById('readouttext'+i).style.left=(3*(i-1)+"px")
  181. }
  182. }
  183. readouttext.style.position="relative"
  184. readouttext.style.top="-20px"
  185. readouttext.style.left=(3*(imagereadoutcount-1)+"px")
  186. }
  187. else{
  188. if(imagereadoutcount>1&&document.getElementById('readouttext'+(imagereadoutcount-1)).offsetLeft>=0){
  189. for(let i=1;i<imagereadoutcount;i++){
  190. document.getElementById('readouttext'+i).style.position="absolute"
  191. let down = 0
  192. for(let u=1;u<i;u++) down+=Math.floor(document.getElementById('readouttext'+u).getBoundingClientRect().height)
  193. document.getElementById('readouttext'+i).style.left="-"+Math.floor(document.getElementById('readouttext'+i).getBoundingClientRect().width)+"px"
  194. document.getElementById('readouttext'+i).style.top=((i-1)*2)+down+"px"
  195. }
  196. }
  197. readouttext.style.position="absolute"
  198. let down = 0
  199. for(let i=1;i<imagereadoutcount;i++) down+=Math.floor(document.getElementById('readouttext'+i).getBoundingClientRect().height)
  200. readouttext.style.left="-"+(Math.floor(readouttext.getBoundingClientRect().width))+"px"
  201. readouttext.style.top=((imagereadoutcount-1)*(2))+down+"px"
  202. }
  203. }
  204.  
  205. function clearimagereadout(){
  206. if (imagereadoutcount>0){
  207. for (let i=1;i<=imagereadoutcount;i++){
  208. document.getElementById('readouttext'+i).setAttribute("style","display:none")
  209. }
  210. imagereadoutcount=0
  211. readoutlinkvar=null
  212. }
  213. }
  214.  
  215. function resizenow(linkvar,width,height){
  216. cancelactiveresizes();
  217.  
  218. let cancelresize = new Promise((_, reject) => cancelactiveresizes = reject);
  219.  
  220. if(towindowsize){
  221. if (window.innerWidth/imagestore[linkvar].width<window.innerHeight/imagestore[linkvar].height){
  222. height=Math.round(imagestore[linkvar].height*window.innerWidth/imagestore[linkvar].width)
  223. width=window.innerWidth
  224. }
  225. else{
  226. width=Math.round(imagestore[linkvar].width*window.innerHeight/imagestore[linkvar].height)
  227. height=window.innerHeight
  228. }
  229. }
  230.  
  231. let imgbtmp = null
  232.  
  233.  
  234. let imgCanvas = document.createElement("canvas"),
  235. imgContext = imgCanvas.getContext("2d");
  236.  
  237. imgCanvas.width=Math.round(width);
  238. imgCanvas.height=Math.round(height);
  239. imgContext.drawImage(imagestore[linkvar], 0, 0, imgCanvas.width, imgCanvas.height);
  240.  
  241. let options = {cancelToken: cancelresize}
  242.  
  243. let starttime = Date.now()
  244.  
  245. resizer.resize(imagestore[linkvar], imgCanvas, options)
  246. .then(function () {
  247. imgCanvas.style.zIndex = 2147483648
  248. imgCanvas.style.visibility = "visible";
  249. imgCanvas.style.position="absolute";
  250. imgCanvas.style.pointerEvents="none";
  251. imgCanvas.style["box-shadow"]="0 0 100px black";
  252.  
  253. if(towindowsize){
  254. if(mydiv==null){
  255. mydiv=document.createElement('div')
  256. mydiv.width="100%"
  257. mydiv.height="100%"
  258. }
  259. mydiv.style.top=Math.round(getScrollTop()+window.innerHeight/2-height/2)+"px";
  260. if(bigscreensankaku&&width>=window.innerWidth-280){
  261. mydiv.style.left=Math.round((window.innerWidth-280)/2-width/2+280-(width-(window.innerWidth-280))/2)+"px";
  262. }
  263. else if(bigscreensankaku){
  264. mydiv.style.left=Math.round((window.innerWidth-280)/2-width/2+280)+"px";
  265. }
  266. else{
  267. mydiv.style.left=Math.round(window.innerWidth/2-width/2)+"px";
  268. }
  269. mydiv.id="mydiv"
  270. mydiv.style.boxSizing="content-box"
  271. mydiv.style.zIndex = 2147483648
  272. mydiv.style.visibility = "visible";
  273. mydiv.style.position="absolute";
  274. mydiv.style.pointerEvents="none";
  275. mydiv.style.display = "block"
  276.  
  277. let scaletime = Date.now()-starttime
  278. if (scaletime < 1000){
  279. imagereadout("Scaling Complete "+(scaletime)+"ms",width,null,2)
  280. }
  281. else if (scaletime <10000){
  282. imagereadout("Scaling Complete "+(Math.round(scaletime/100)/10)+"s",width,null,2)
  283. }
  284. else{
  285. imagereadout("Scaling Complete "+(Math.round(scaletime/1000))+"s",width,null,2)
  286. }
  287.  
  288. if(document.getElementById('upscaledimgcanvas2') !== null){
  289. mydiv.replaceChild(imgCanvas,document.getElementById('upscaledimgcanvas2'));
  290. }
  291. else{
  292. document.body.parentNode.insertBefore(mydiv,null);
  293. mydiv.insertBefore(imgCanvas,null);
  294. }
  295. imgCanvas.id="upscaledimgcanvas2";
  296. setlast=2
  297. }
  298. else{
  299. if(document.getElementById('upscaledimgcanvas') !== null){
  300. maindiv.replaceChild(imgCanvas,document.getElementById('upscaledimgcanvas'));
  301. }
  302. else{
  303. maindiv.insertBefore(imgCanvas,maindiv.firstChild);
  304. }
  305. imgCanvas.id="upscaledimgcanvas";
  306. setlast=1
  307. }
  308. inprogress="null?"
  309. currentpic = linkvar
  310. clearTimeout(imagestore[linkvar+"myexpire"])
  311. imagestore[linkvar+"myexpire"]=setTimeout(purgeimage,purgewaittime,linkvar)
  312. })
  313. .catch(function (err) {
  314.  
  315. inprogress="null?"
  316. throw err;
  317. });
  318. }
  319.  
  320. function checkfordiv(){
  321. if (maindiv==null){
  322. let divs = document.getElementsByTagName("div")
  323. for (let div of divs) {
  324. if (div.style.zIndex == 2147483647) {
  325. clearInterval(divchecking)
  326. maindiv = div
  327. resize_ob.observe(maindiv);
  328. }
  329. }
  330. }
  331. }
  332.  
  333.  
  334. function loop(){
  335. if (maindiv.style.display !== "none") {
  336. }
  337. }
  338.  
  339. let downloadstarttime = null
  340. let bigscreensankaku = false
  341. let thingie = null
  342. let inprogressh = null
  343. let inprogressw = null
  344.  
  345. let originalbutton = null
  346.  
  347. let requestcount = 0
  348. let lastinprogress
  349.  
  350. function isCanvas(i) {
  351. return i instanceof HTMLCanvasElement;
  352. }
  353.  
  354.  
  355.  
  356. function grabimg_and_resize(linkvar,w,h){
  357.  
  358. if(linkvar!==null &&linkvar!== undefined&&linkvar!== ""&&bigscreensankaku){
  359. if (imagestore[linkvar+"myoriginal"]){
  360. linkvar = imagestore[linkvar+"myoriginal"]
  361. }
  362.  
  363. let linkvarsplit=null
  364.  
  365. if(linkvar.search("sample")!==-1){
  366. linkvarsplit=linkvar.split("-")[1].split(".")[0]
  367. }
  368. else if(linkvar.search("preview")!==-1){
  369. linkvarsplit=linkvar.split("/")[7].split(".")[0]
  370. }
  371. else{
  372. linkvarsplit=linkvar.split("/")[6].split(".")[0]
  373. }
  374.  
  375. let originalfound=false
  376. for(let key in imagestore){
  377. if(key.search("myexpire")==-1&&key.search("myoriginal")==-1&&key.search("preview")==-1){
  378. let keysplit=null
  379. if(key.search("sample")!==-1){
  380. keysplit=key.split("-")[1].split(".")[0]
  381. }
  382. else{
  383. keysplit=key.split("/")[6].split(".")[0]
  384. }
  385. if(key.search("sample")==-1){
  386. if(linkvarsplit==keysplit){
  387. linkvar = key
  388. console.log("found previously saved original key | "+key)
  389. originalfound=true
  390. break
  391. }
  392. }
  393. }
  394. }
  395. if(linkvar.search("sample")==-1&&linkvar.search("preview")==-1){
  396. originalfound=true
  397. }
  398. if(!originalfound){
  399.  
  400. for(let key in imagestore){
  401. if(key.search("myexpire")==-1&&key.search("myoriginal")==-1&&key.search("preview")==-1){
  402. let keysplit=null
  403. if(key.search("sample")!==-1){
  404. keysplit=key.split("-")[1].split(".")[0]
  405. }
  406. else{
  407. keysplit=key.split("/")[6].split(".")[0]
  408. }
  409. if(linkvarsplit==keysplit){
  410. linkvar=key
  411. break
  412. }
  413. }
  414. }
  415. }
  416. }
  417.  
  418. towindowsize=false
  419. if (bigscreensankaku||w<window.innerWidth && h<window.innerHeight && w==mainimg.naturalWidth || w<window.innerWidth && h<window.innerHeight && w>window.innerWidth-30 || w<window.innerWidth && h<window.innerHeight && h>window.innerHeight-30||bigscreensankaku){
  420.  
  421. if (window.innerWidth/w<window.innerHeight/h){
  422. h=Math.round(h*window.innerWidth/w)
  423. w=window.innerWidth
  424. }
  425. else{
  426. w=Math.round(w*window.innerHeight/h)
  427. h=window.innerHeight
  428. }
  429. towindowsize = true
  430. }
  431. if(linkvar!==null &&linkvar!== undefined&&linkvar!== ""&&linkvar.split("?")[0]==inprogress.split("?")[0]&&inprogressh==h&&inprogressw==w){
  432. }
  433. else if (linkvar==currentpic&&inprogressh==h&&inprogressw==w){
  434. if(document.getElementById('mydiv')==null){
  435. mydiv=document.createElement('div')
  436. mydiv.width="100%"
  437. mydiv.height="100%"
  438. }
  439. else{
  440. mydiv = document.getElementById('mydiv')
  441. if(document.getElementById('upscaledimgcanvas2')){
  442. w=document.getElementById('upscaledimgcanvas2').width
  443. h=document.getElementById('upscaledimgcanvas2').height
  444. }
  445. }
  446. mydiv.style.top=Math.round(getScrollTop()+window.innerHeight/2-h/2)+"px";
  447. if(bigscreensankaku&&w>=window.innerWidth-280){
  448. mydiv.style.left=Math.round((window.innerWidth-280)/2-w/2+280-(w-(window.innerWidth-280))/2)+"px";
  449. }
  450. else if(bigscreensankaku){
  451. mydiv.style.left=Math.round((window.innerWidth-280)/2-w/2+280)+"px";
  452. }
  453. else{
  454. mydiv.style.left=Math.round(window.innerWidth/2-w/2)+"px";
  455. }
  456. mydiv.id="mydiv"
  457. if(document.getElementById('mydiv') !== null){
  458. if(setlast==2){
  459. document.getElementById('mydiv').setAttribute("style","display: block;visibility: visible;z-index: 2147483647;box-sizing: content-box;position: absolute;pointer-events: none;top:"+document.getElementById('mydiv').style.top+";left:"+document.getElementById('mydiv').style.left+";")
  460.  
  461. document.getElementById('mydiv').style.top=Math.floor(getScrollTop()+window.innerHeight/2-h/2)+"px";
  462. }
  463. }
  464. if(document.getElementById('upscaledimgcanvas') !== null){
  465. if(setlast==1){
  466. document.getElementById('upscaledimgcanvas').setAttribute("style","z-index: 2147483647;display:block;position:absolute;visibility:visible;")
  467. }
  468. }
  469. }
  470. else{
  471.  
  472. if(linkvar!==null &&linkvar!== undefined&&linkvar!== ""){
  473.  
  474. if(linkvar.search(".mp4")==-1&&linkvar.search(".webm")==-1&&linkvar.search(".flv")==-1){
  475.  
  476. if(inprogress.split("?")[0]!== linkvar.split("?")[0]){
  477. cancelactiveresizes();
  478.  
  479. if(linkvar.search("sankakucomplex.com")!==-1){
  480. let linkvarsplit
  481. if(linkvar.search("sample")!==-1){
  482. linkvarsplit=linkvar.split("-")[1].split(".")[0]
  483. }
  484. else if(linkvar.search("preview")!==-1){
  485. linkvarsplit=linkvar.split("/")[7].split(".")[0]
  486. }
  487. else{
  488. linkvarsplit=linkvar.split("/")[6].split(".")[0]
  489. }
  490. let lastinprogresssplit
  491. if(lastinprogress&&lastinprogress!=="null?"){
  492. if(lastinprogress.search("sample")!==-1){
  493. lastinprogresssplit=lastinprogress.split("-")[1].split(".")[0]
  494. }
  495. else if(lastinprogress.search("preview")!==-1){
  496. lastinprogresssplit=lastinprogress.split("/")[7].split(".")[0]
  497. }
  498. else{
  499. lastinprogresssplit=lastinprogress.split("/")[6].split(".")[0]
  500. }
  501. }
  502. }
  503.  
  504. if(towindowsize){
  505. let tempimage = document.createElement('img');
  506. tempimage.setAttribute("src", linkvar);
  507. tempimage.width = Math.round(w)
  508. tempimage.height = Math.round(h)
  509.  
  510. tempimage.style.zIndex = 2147483648
  511. tempimage.style.visibility = "visible";
  512. tempimage.style.position="absolute";
  513. tempimage.style.pointerEvents="none";
  514. tempimage.style["box-shadow"]="0 0 100px black";
  515.  
  516. if(document.getElementById('mydiv')==null){
  517. mydiv=document.createElement('div')
  518. mydiv.width="100%"
  519. mydiv.height="100%"
  520. }
  521. else{
  522. mydiv = document.getElementById('mydiv')
  523. }
  524. mydiv.style.top=Math.round(getScrollTop()+window.innerHeight/2-h/2)+"px";
  525. if(bigscreensankaku&&w>=window.innerWidth-280){
  526. mydiv.style.left=Math.round((window.innerWidth-280)/2-w/2+280-(w-(window.innerWidth-280))/2)+"px";
  527. }
  528. else if(bigscreensankaku){
  529. mydiv.style.left=Math.round((window.innerWidth-280)/2-w/2+280)+"px";
  530. }
  531. else{
  532. mydiv.style.left=Math.round(window.innerWidth/2-w/2)+"px";
  533. }
  534. mydiv.id="mydiv"
  535. mydiv.style.boxSizing="content-box"
  536. mydiv.style.zIndex = 2147483648
  537. mydiv.style.visibility = "visible";
  538. mydiv.style.position="absolute";
  539. mydiv.style.pointerEvents="none";
  540. mydiv.style.display = "block"
  541. if(document.getElementById('mydiv')==null){
  542. document.body.parentNode.insertBefore(mydiv,null);
  543. }
  544. if(document.getElementById('upscaledimgcanvas2') !== null){
  545. mydiv.replaceChild(tempimage,document.getElementById('upscaledimgcanvas2'));
  546. }
  547. else{
  548. mydiv.insertBefore(tempimage,null)
  549. }
  550. tempimage.id="upscaledimgcanvas2";
  551.  
  552. clearimagereadout()
  553.  
  554. if(linkvar.search("sankakucomplex.com")!==-1){
  555. imagereadout(getSankImageType(linkvar),w,linkvar)
  556. }
  557. }
  558.  
  559.  
  560. lastinprogress=linkvar
  561. inprogress = linkvar
  562. inprogressh=h
  563. inprogressw=w
  564.  
  565. let spin =0
  566. function spinselect(input){
  567. if(input==1) return "-"
  568. if(input==2) return "\\"
  569. if(input==3) return "|"
  570. if(input==4) return "/"
  571. }
  572.  
  573. function loadFailed(){
  574. imagereadout("Failed to load image",w)
  575. }
  576.  
  577. if(linkvar.search(".gif")==-1){
  578. if (imagestore[linkvar]==null||imagestore[linkvar]==undefined){
  579. requestcount+=1
  580. let startsource = linkvar
  581. let starttime = Date.now()
  582. downloadstarttime = Date.now()
  583. setTimeout(function() {
  584. imgfirstload = true
  585. GM_xmlhttpRequest({
  586. method: 'GET',
  587. url: startsource,
  588. responseType: 'blob',
  589. onload: function(resp) {
  590. let requesttime = Date.now()-downloadstarttime
  591. if (requesttime < 1000){
  592. imagereadout("Image Request "+(requesttime)+"ms",w,linkvar,2)
  593. }
  594. else if (requesttime <10000){
  595. imagereadout("Image Request "+(Math.round(requesttime/100)/10)+"s",w,linkvar,2)
  596. }
  597. else{
  598. imagereadout("Image Request "+(Math.round(requesttime/1000))+"s",w,linkvar,2)
  599. }
  600. imagereadout("Scaling... ",w)
  601. starttime = Date.now()
  602. if (resp.response.type !== "image/gif"){
  603. const img = new Image()
  604. img.onload = (event) => {
  605. URL.revokeObjectURL(event.target.src)
  606. imagestore[startsource] = document.createElement("canvas")
  607. imagestore[startsource].width = img.width
  608. imagestore[startsource].height = img.height
  609. let ctx = imagestore[startsource].getContext("2d")
  610. ctx.drawImage(event.target, 0, 0)
  611. imagestore[startsource+"myexpire"]=setTimeout(purgeimage,purgewaittime,startsource)
  612. if(mainimg!==null&&mainimg!==undefined){
  613. if(startsource == mainimg.src && w!==imagestore[startsource].width) {
  614. resizenow(linkvar,w,h);
  615. }
  616. else inprogress="null?"
  617. }
  618. if(thingie!==null){
  619. if(startsource==thingie.src&&bigscreensankaku) {
  620. resizenow(linkvar,w,h);
  621. }
  622. else inprogress="null?"
  623. }
  624. }
  625. img.src = URL.createObjectURL(resp.response)
  626. }
  627. },
  628. onerror: loadFailed,
  629. onabort: loadFailed,
  630. onprogress: function(){
  631. spin+=1
  632. imagereadout("Requesting Image "+spinselect(spin)+" ",w,linkvar,2)
  633. if (spin>=4) spin=0
  634. },
  635. onloadstart: function(){
  636. starttime = Date.now()
  637. imagereadout("Requesting Image / ",w,linkvar)
  638. }
  639. });
  640. }, 0);
  641. }
  642. else {
  643. imagereadout("Scaling... ",w)
  644. resizenow(linkvar,w,h);
  645. }
  646. }
  647. else {
  648. imagereadout("HQ Gif Scaling Not Supported")
  649. inprogress="null?"
  650. }
  651. }
  652. }
  653.  
  654. else{
  655. cancelactiveresizes();
  656. if(document.getElementById('mydiv') !== null){
  657. if(document.getElementById('mydiv').style.display !== "none"){
  658. document.getElementById('mydiv').setAttribute("style","display:none;top:"+document.getElementById('mydiv').style.top+";left:"+document.getElementById('mydiv').style.left+";")
  659. }
  660. }
  661. if(document.getElementById('upscaledimgcanvas') !== null){
  662. if(document.getElementById('upscaledimgcanvas').style.display !== "none" && document.getElementById('upscaledimgcanvas').style.display !== null){
  663. document.getElementById('upscaledimgcanvas').setAttribute("style","display:none;top:"+document.getElementById('upscaledimgcanvas').style.top+";left:"+document.getElementById('upscaledimgcanvas').style.left+";")
  664. }
  665. }
  666. }
  667.  
  668. }
  669. else{
  670. cancelactiveresizes();
  671. if(document.getElementById('mydiv') !== null){
  672. if(document.getElementById('mydiv').style.display !== "none"){
  673. document.getElementById('mydiv').setAttribute("style","display:none;top:"+document.getElementById('mydiv').style.top+";left:"+document.getElementById('mydiv').style.left+";")
  674. }
  675. }
  676. if(document.getElementById('upscaledimgcanvas') !== null){
  677. if(document.getElementById('upscaledimgcanvas').style.display !== "none" && document.getElementById('upscaledimgcanvas').style.display !== null){
  678. document.getElementById('upscaledimgcanvas').setAttribute("style","display:none;top:"+document.getElementById('upscaledimgcanvas').style.top+";left:"+document.getElementById('upscaledimgcanvas').style.left+";")
  679. }
  680. }
  681. }
  682. }
  683.  
  684. }
  685.  
  686. const resize_ob = new ResizeObserver(function(entries) {
  687. if(bigscreensankaku==false){
  688. cancelactiveresizes();
  689.  
  690. let rect = entries[0].contentRect;
  691.  
  692. let w = rect.width;
  693. let h = rect.height;
  694.  
  695. if(document.getElementById('upscaledimgcanvas') !== null){
  696. document.getElementById('upscaledimgcanvas').setAttribute("style","display:none;top:"+document.getElementById('upscaledimgcanvas').style.top+";left:"+document.getElementById('upscaledimgcanvas').style.left+";")
  697. }
  698. if(document.getElementById('upscaledimgcanvas2') !== null){
  699. document.getElementById('mydiv').setAttribute("style","display:none;top:"+document.getElementById('mydiv').style.top+";left:"+document.getElementById('mydiv').style.left+";")
  700. }
  701.  
  702. if (h !== 0){
  703. if(mainimg == null){
  704. function checkforimg(input){
  705. for (let elem of input){
  706. if (elem.nodeName.toLowerCase() == "img") {
  707. return elem;
  708. }
  709. }
  710. return "wtf didn't find img"
  711. }
  712. mainimg = checkforimg(Array.from(maindiv.children))
  713. mainimg.style.position="relative";
  714. mainimg.style.zIndex=2147483646
  715. }
  716.  
  717. grabimg_and_resize(mainimg.src,w,h)
  718. }
  719. }
  720. });
  721.  
  722. let divchecking = setInterval(checkfordiv,300)
  723.  
  724. function getScrollTop() {
  725. if (typeof window.pageYOffset !== "undefined" ) {
  726. return window.pageYOffset;
  727. }
  728.  
  729. let d = document.documentElement;
  730. if (typeof d.clientHeight !== "undefined") {
  731. return d.scrollTop;
  732. }
  733.  
  734. return document.body.scrollTop;
  735. }
  736. let lastthingietop = null
  737. let setlast = 0
  738. let thingietop = null
  739. let inprogress = "null?"
  740.  
  741. const sankobservob = new MutationObserver(function(mutationsList, observer){
  742.  
  743. if (bigscreensankaku){
  744. for (let elem of document.getElementsByClassName("swiper-slide swiper-slide-active")){
  745. if (elem.className.endsWith("active")){
  746.  
  747. thingietop = elem
  748. thingie = elem.firstChild.firstChild.firstChild.firstChild
  749. if(thingie!==null&&thingie!==undefined){
  750. sankobservob.disconnect()
  751. sankobservob.observe(thingietop, {attributes: true});
  752. psankobservob.disconnect()
  753. psankobservob.observe(thingie, {attributes: true, attributeOldValue: true});
  754. grabimg_and_resize(thingie.src,thingie.naturalWidth,thingie.naturalHeight)
  755. break
  756. }
  757. }
  758. }
  759. lastthingietop = thingietop
  760. }
  761. })
  762.  
  763. const psankobservob = new MutationObserver(function(mutationsList, observer){
  764. for(const mutation of mutationsList) {
  765. if (mutation.type=='attributes'&&mutation.attributeName=="src"&&bigscreensankaku&&thingietop.firstChild.firstChild.firstChild.firstChild==thingie){
  766. if(mutation.oldValue!==null&&mutation.oldValue!==undefined){
  767. if (mutation.oldValue.search("sample")!==-1||mutation.oldValue.search("preview")!==-1){
  768. if(thingie.src.search("sample")==-1&&thingie.src.search("preview")==-1){
  769. imagestore[mutation.oldValue+"myoriginal"] = thingie.src
  770. }
  771. }
  772. }
  773. grabimg_and_resize(thingie.src,thingie.naturalWidth,thingie.naturalHeight)
  774. }
  775.  
  776. }
  777. })
  778.  
  779. const buttonob = new MutationObserver(function(){
  780. originalbutton.click();
  781. })
  782.  
  783. document.addEventListener('keydown', function (zEvent) {
  784. if (zEvent.key == "m"){
  785. if(document.getElementById('mydiv') !== null){
  786. if(document.getElementById('mydiv').style.display !== "none"){
  787. document.getElementById('mydiv').setAttribute("style","display:none;top:"+document.getElementById('mydiv').style.top+";left:"+document.getElementById('mydiv').style.left+";")
  788. setlast = 2
  789. }
  790. else if(setlast==2){
  791. document.getElementById('mydiv').setAttribute("style","display: block;visibility: visible;z-index: 2147483647;box-sizing: content-box;position: absolute;pointer-events: none;top:"+document.getElementById('mydiv').style.top+";left:"+document.getElementById('mydiv').style.left+";")
  792. }
  793. }
  794. if(document.getElementById('upscaledimgcanvas') !== null){
  795. if(document.getElementById('upscaledimgcanvas').style.display !== "none" && document.getElementById('upscaledimgcanvas').style.display !== null){
  796. document.getElementById('upscaledimgcanvas').setAttribute("style","display:none;top:"+document.getElementById('upscaledimgcanvas').style.top+";left:"+document.getElementById('upscaledimgcanvas').style.left+";")
  797. setlast = 1
  798. }
  799. else if(setlast==1){
  800. document.getElementById('upscaledimgcanvas').setAttribute("style","z-index: 2147483647;display:block;position:absolute;visibility:visible;")
  801. }
  802. }
  803. }
  804. else if (zEvent.key == "n"){
  805. bigscreensankaku = !bigscreensankaku
  806.  
  807. if (bigscreensankaku){
  808. for (let elem of document.getElementsByClassName("swiper-slide swiper-slide-active")){
  809. if (elem.className.endsWith("active")){
  810. thingietop = elem
  811. thingie = elem.firstChild.firstChild.firstChild.firstChild
  812. if(thingie!==null&&thingie!==undefined){
  813. sankobservob.disconnect()
  814. sankobservob.observe(thingietop, {attributes: true});
  815. psankobservob.disconnect()
  816. psankobservob.observe(thingie, {attributes: true, attributeOldValue: true});
  817. grabimg_and_resize(thingie.src)
  818. break
  819. }
  820. }
  821. }
  822. }
  823. else{
  824. psankobservob.disconnect()
  825. sankobservob.disconnect()
  826. }
  827. if(document.getElementById('mydiv') !== null){
  828. if(document.getElementById('mydiv').style.display !== "none"){
  829. document.getElementById('mydiv').setAttribute("style","display:none;top:"+document.getElementById('mydiv').style.top+";left:"+document.getElementById('mydiv').style.left+";")
  830. }
  831. }
  832. }
  833. else if(zEvent.key == "0"){
  834. imagereadout("Waiting for server",null,inprogress!=="null?"?inprogress:currentpic)
  835. let originalsearch = document.getElementsByName("post_mode")
  836. if(originalsearch){
  837. for (let i = 0; i < originalsearch.length; i++) {
  838. if(originalsearch[i].getAttribute("value") == "original"){
  839. if(window.getComputedStyle(originalsearch[i]).getPropertyValue('color') !== "rgb(255, 140, 0)") {
  840. originalsearch[i].click();
  841. originalbutton = originalsearch[i]
  842. let textsearch =document.getElementsByClassName('MuiTypography-root')
  843. }
  844. }
  845. }
  846. }
  847. }
  848. });
  849.  
  850. let leftareasize = 20
  851. document.addEventListener('click', function (e) {
  852. if (e.button==0&&e.mozInputSource==1&&e.pageX <=leftareasize&&window.location.href.includes("/post/")){
  853. let listofel = document.getElementsByClassName("MuiButtonBase-root MuiFab-root")
  854. if(listofel){
  855.  
  856. for (let i = 0; i < listofel.length; i++) {
  857. if(listofel[i].getAttribute("aria-label") == "Prev"){
  858. listofel[i].click();
  859. break
  860. }
  861. }
  862. }
  863. }
  864. });
  865.  
  866. document.addEventListener('mousemove', e => {
  867. if(window.location.href.includes("https://beta.sankakucomplex.com")){
  868. if (e.pageX <=leftareasize&&!bigscreensankaku&&window.location.href.includes("/post/")){
  869. bigscreensankaku = !bigscreensankaku
  870.  
  871. if (bigscreensankaku){
  872. for (let elem of document.getElementsByClassName("swiper-slide swiper-slide-active")){
  873. if (elem.className.endsWith("active")){
  874. thingietop = elem
  875. thingie = elem.firstChild.firstChild.firstChild.firstChild
  876. if(thingie!==null&&thingie!==undefined){
  877. sankobservob.disconnect()
  878. sankobservob.observe(thingietop, {attributes: true});
  879. psankobservob.disconnect()
  880. psankobservob.observe(thingie, {attributes: true, attributeOldValue: true});
  881. grabimg_and_resize(thingie.src,thingie.naturalWidth,thingie.naturalHeight)
  882. }
  883. }
  884. }
  885. }
  886. }
  887. else if(e.pageX >leftareasize&&bigscreensankaku){
  888. bigscreensankaku = !bigscreensankaku
  889. cancelactiveresizes();
  890. psankobservob.disconnect()
  891. sankobservob.disconnect()
  892. if(document.getElementById('mydiv') !== null){
  893. if(document.getElementById('mydiv').style.display !== "none"){
  894. document.getElementById('mydiv').setAttribute("style","display:none;top:"+document.getElementById('mydiv').style.top+";left:"+document.getElementById('mydiv').style.left+";")
  895. }
  896. }
  897. }
  898. }
  899. });
  900. })();