Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script>
- <form method="POST" enctype="multipart/form-data" action="https://www.google.com/save" id="myForm">
- <input type="hidden" name="img_val" id="img_val" value="" />
- </form>
- <script>
- window.take = function() {
- html2canvas(document.getElementsByClassName("d-flex flex-row comment-row p-l-0 m-t-0 m-b-0 selected"), {
- width: 750,
- onrendered: function (canvas) {
- document.getElementById('img_val').value = canvas.toDataURL("image/png");
- //document.getElementById("myForm").submit();
- postToImgur()
- }
- })
- }
- window.postToImgur = function postToImgur() {
- var formData = new FormData();
- formData.append("image", document.getElementById("img_val").value);
- $.ajax({
- url: 'https://api.imgur.com/3/image',
- method: 'POST',
- headers: {
- "Authorization": "Client-ID " + "d297fd441566f99",
- Accept: 'application/json'
- },
- data: {
- image: document.getElementById("img_val").value.replace("data:image/png;base64,", ""),
- type: 'base64'
- },
- success: function(result) {
- var id = result.data.id;
- alert('https://i.imgur.com/' + id + '.png');
- }
- });
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement