-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch_svg.js
36 lines (35 loc) · 1.44 KB
/
fetch_svg.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
let view = document.querySelector(".punch-viewer-content");
let intervalId;
let currentPageNumber = parseInt(document.body.querySelector(".goog-inline-block .docs-material-menu-button-flat-default-caption").innerText);
let numDiapositive = parseInt(document.querySelector(".goog-inline-block.docs-material-menu-button-flat-default-caption[aria-setsize]").getAttribute("aria-setsize"));
function downloadSVG() {
let svgContainer = document.querySelector(".punch-viewer-svgpage-svgcontainer");
let svg = svgContainer.querySelector("svg");
let svgString = new XMLSerializer().serializeToString(svg);
let blob = new Blob([svgString], { type: "image/svg+xml;charset=utf-8" });
let url = window.URL.createObjectURL(blob);
let a = document.createElement("a");
a.href = url;
a.download = "Diapositiva 0" + currentPageNumber + ".svg";
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
document.body.removeChild(a);
}
function autoSlide() {
view.click();
setTimeout(function () {
let nextPageNumber = parseInt(document.body.querySelector(".goog-inline-block .docs-material-menu-button-flat-default-caption").innerText);
if (nextPageNumber === numDiapositive) {
clearInterval(intervalId);
currentPageNumber = nextPageNumber;
downloadSVG();
return;
} else {
currentPageNumber = nextPageNumber;
downloadSVG();
}
}, 100);
}
downloadSVG();
intervalId = setInterval(autoSlide, 300);