Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script>
  2. <form method="POST" enctype="multipart/form-data" action="https://www.google.com/save" id="myForm">
  3. <input type="hidden" name="img_val" id="img_val" value="" />
  4. </form>
  5.  
  6. <script>
  7. window.take = function() {
  8. html2canvas(document.getElementsByClassName("d-flex flex-row comment-row p-l-0 m-t-0 m-b-0 selected"), {
  9. width: 750,
  10. onrendered: function (canvas) {
  11. document.getElementById('img_val').value = canvas.toDataURL("image/png");
  12. //document.getElementById("myForm").submit();
  13. postToImgur()
  14. }
  15. })
  16. }
  17.  
  18. window.postToImgur = function postToImgur() {
  19. var formData = new FormData();
  20. formData.append("image", document.getElementById("img_val").value);
  21. $.ajax({
  22. url: 'https://api.imgur.com/3/image',
  23. method: 'POST',
  24. headers: {
  25. "Authorization": "Client-ID " + "d297fd441566f99",
  26. Accept: 'application/json'
  27. },
  28. data: {
  29. image: document.getElementById("img_val").value.replace("data:image/png;base64,", ""),
  30. type: 'base64'
  31. },
  32. success: function(result) {
  33. var id = result.data.id;
  34. alert('https://i.imgur.com/' + id + '.png');
  35. }
  36. });
  37.  
  38. }
  39. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement