summaryrefslogtreecommitdiff
path: root/crocoite/data
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2017-11-22 11:30:51 +0100
committerLars-Dominik Braun <lars@6xq.net>2017-11-22 11:30:51 +0100
commit5f6343a37b36a0008b2c2a2a7805fcdb907aa9f5 (patch)
treecbfffad34a69dbd2146abb6693c3d03bcd0b4ed8 /crocoite/data
parent9cff3074e52b91c49298f80fd3e73d77f1f1c7dd (diff)
downloadcrocoite-5f6343a37b36a0008b2c2a2a7805fcdb907aa9f5.tar.gz
crocoite-5f6343a37b36a0008b2c2a2a7805fcdb907aa9f5.tar.bz2
crocoite-5f6343a37b36a0008b2c2a2a7805fcdb907aa9f5.zip
Make <canvas> static before DOM snapshot
Use --run-before-snapshot=canvas-snapshot.js. Replaces <canvas> with image snapshot. We could use .captureStream() as well.
Diffstat (limited to 'crocoite/data')
-rw-r--r--crocoite/data/canvas-snapshot.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/crocoite/data/canvas-snapshot.js b/crocoite/data/canvas-snapshot.js
new file mode 100644
index 0000000..2395411
--- /dev/null
+++ b/crocoite/data/canvas-snapshot.js
@@ -0,0 +1,18 @@
+/* Replace canvas with image snapshot
+ */
+(function(){
+ var canvas = document.querySelectorAll ("canvas");
+ for (var i = 0; i < canvas.length; i++) {
+ var c = canvas[i];
+ var data = c.toDataURL ();
+ var parent = c.parentNode;
+ var img = document.createElement ('img');
+ /* copy all attributes */
+ for (var i = 0; i < c.attributes.length; i++) {
+ var attr = c.attributes.item(i);
+ img.setAttribute (attr.nodeName, attr.nodeValue);
+ }
+ img.src = data;
+ parent.replaceChild (img, c);
+ }
+}());