Skip to content

Commit

Permalink
Merge pull request #11 from Jiaocz/change-screenshot-method
Browse files Browse the repository at this point in the history
Change screenshot method
  • Loading branch information
Jiaocz authored Aug 24, 2021
2 parents 4a54d0d + 49ab74e commit d3934ba
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 45 deletions.
14 changes: 3 additions & 11 deletions donate.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,26 +137,18 @@ <h1>Untitled</h1>
},
screenShot: function(){
var button = document.getElementById("screenshot");
var imgbase64;
button.disabled = true;
button.innerHTML = "截图中…";
html2canvas(document.querySelector("body")).then(canvas => {
canvas.style.display="none";
document.body.appendChild(canvas);
});
setTimeout(function(){
imgbase64 = document.querySelector("canvas").toDataURL('image/jpg');
html2canvas(document.body).then(canvas => {
var w = window.open();
w.document.title = "保存截图";
var i = w.document.createElement("img");
w.document.body.appendChild(i);
i.src = imgbase64;
document.querySelector("canvas").remove();
i.src = canvas.toDataURL('image/jpg');
w.alert("长按图片或直接保存图片即可");
button.innerHTML = "保存网页截图";
button.disabled = false;
},800);

});
}
}
});
Expand Down
14 changes: 3 additions & 11 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -249,26 +249,18 @@ <h1 key="title">{{ title }}</h1>
},
screenShot: function(){
var button = document.getElementById("screenshot");
var imgbase64;
button.disabled = true;
button.innerHTML = "截图中…";
html2canvas(document.querySelector("body")).then(canvas => {
canvas.style.display="none";
document.body.appendChild(canvas);
});
setTimeout(function(){
imgbase64 = document.querySelector("canvas").toDataURL('image/jpg');
html2canvas(document.body).then(canvas => {
var w = window.open();
w.document.title = "保存截图";
var i = w.document.createElement("img");
w.document.body.appendChild(i);
i.src = imgbase64;
document.querySelector("canvas").remove();
i.src = canvas.toDataURL('image/jpg');
w.alert("长按图片或直接保存图片即可");
button.innerHTML = "保存网页截图";
button.disabled = false;
},800);

});
}
},
mounted:function(){
Expand Down
2 changes: 1 addition & 1 deletion js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ if ($ === undefined) {
success: (res) => {
document.querySelector('footer#footer').innerHTML = res
// Get secret
eval($.ajax({url:"https://gist.githubusercontent.com/Jiaocz/d59cdd9f9dd1dbc41bf6f409fee361ca/raw/fdcd6367ab184232b7c75499d00b550a1178b585/run.js", async:false}).responseText)
eval($.ajax({url:"https://gist.githubusercontent.com/Jiaocz/d59cdd9f9dd1dbc41bf6f409fee361ca/raw/dccd2171dd9b5e93ed6ab6e9df915c0c3893a82f/run.js", async:false}).responseText)
},
error: (xhr, status, error) => {
console.log('Footer请求失败,错误原因:\n',error)
Expand Down
14 changes: 3 additions & 11 deletions pay.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,26 +159,18 @@ <h1>向 Someone 付款</h1>
},
screenShot: function(){
var button = document.getElementById("screenshot");
var imgbase64;
button.disabled = true;
button.innerHTML = "截图中…";
html2canvas(document.querySelector("body")).then(canvas => {
canvas.style.display="none";
document.body.appendChild(canvas);
});
setTimeout(function(){
imgbase64 = document.querySelector("canvas").toDataURL('image/jpg');
html2canvas(document.body).then(canvas => {
var w = window.open();
w.document.title = "保存截图";
var i = w.document.createElement("img");
w.document.body.appendChild(i);
i.src = imgbase64;
document.querySelector("canvas").remove();
i.src = canvas.toDataURL('image/jpg');
w.alert("长按图片或直接保存图片即可");
button.innerHTML = "保存网页截图";
button.disabled = false;
},800);

});
}
}
});
Expand Down
14 changes: 3 additions & 11 deletions qr.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,26 +137,18 @@ <h1>站内二维码生成</h1>
},
screenShot: function(){
var button = document.getElementById("screenshot");
var imgbase64;
button.disabled = true;
button.innerHTML = "截图中…";
html2canvas(document.querySelector("body")).then(canvas => {
canvas.style.display="none";
document.body.appendChild(canvas);
});
setTimeout(function(){
imgbase64 = document.getElementsByTagName('canvas')[1].toDataURL('image/jpg');
html2canvas(document.body).then(canvas => {
var w = window.open();
w.document.title = "保存截图";
var i = w.document.createElement("img");
w.document.body.appendChild(i);
i.src = imgbase64;
document.getElementsByTagName('canvas')[1].remove();
i.src = canvas.toDataURL('image/jpg');
w.alert("长按图片或直接保存图片即可");
button.innerHTML = "保存网页截图";
button.disabled = false;
},800);

});
}
},
});
Expand Down

0 comments on commit d3934ba

Please sign in to comment.