diff --git a/lib/polyfill.coffee b/lib/polyfill.coffee index 5d9ddc124..3cec1905a 100644 --- a/lib/polyfill.coffee +++ b/lib/polyfill.coffee @@ -1,6 +1,16 @@ Polyfill = init: -> + Polyfill.toBlob() Polyfill.visibility() + toBlob: -> + HTMLCanvasElement::toBlob or= (cb) -> + data = atob @toDataURL()[22..] + # DataUrl to Binary code from Aeosynth's 4chan X repo + l = data.length + ui8a = new Uint8Array l + for i in [0...l] + ui8a[i] = data.charCodeAt i + cb new Blob [ui8a], type: 'image/png' visibility: -> # page visibility API return unless 'webkitHidden' of document diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index fc7b0357b..791802066 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -595,21 +595,9 @@ QR = cv.width = img.width = width cv.getContext('2d').drawImage img, 0, 0, width, height URL.revokeObjectURL fileURL - applyBlob = (blob) => + cv.toBlob (blob) => @URL = URL.createObjectURL blob @nodes.el.style.backgroundImage = "url(#{@URL})" - if cv.toBlob - cv.toBlob applyBlob - return - data = atob cv.toDataURL().split(',')[1] - - # DataUrl to Binary code from Aeosynth's 4chan X repo - l = data.length - ui8a = new Uint8Array l - for i in [0...l] - ui8a[i] = data.charCodeAt i - - applyBlob new Blob [ui8a], type: 'image/png' fileURL = URL.createObjectURL @file img.src = fileURL