Created
August 27, 2019 10:54
-
-
Save tsweeper/cd3ffe980c5393a738226da8cb652c40 to your computer and use it in GitHub Desktop.
Convert and extract canvas contents into image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// Convert canvas content into image. | |
| /// Usage: Run this script in console. | |
| /*************************************************************** | |
| * Warning Notice | |
| * | |
| * This script is provided for EDUCATIONAL PURPOSES ONLY. | |
| * Do NOT use this script for illegal or copyright infringement activities. | |
| * | |
| * This script is free software; you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation; either version 3 of the License, or | |
| * (at your option) any later version. | |
| * | |
| * The GNU General Public License can be found at | |
| * http://www.gnu.org/copyleft/gpl.html. | |
| * | |
| * This script is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| * GNU General Public License for more details. | |
| * | |
| * This notice MUST APPEAR in all copies of the script! | |
| ***************************************************************/ | |
| // create new window with blank document | |
| var w = window.open("", document.title); | |
| // create new document | |
| var newDoc = document.implementation.createHTMLDocument("New Document"); | |
| newDoc.body.style = "margin: 0px; background: #0e0e0e;"; | |
| newDoc.title = document.title; | |
| // add front image if found | |
| try { | |
| var frontimg = document.getElementsByClassName('front-link-page')[0].querySelectorAll('img')[0]; | |
| frontimg.style = "display: block;margin: auto;"; | |
| newDoc.body.appendChild(frontimg); | |
| } | |
| catch { | |
| console.log("front-link-page not found"); | |
| } | |
| // get every canvas then convert into array to use forEach | |
| var canvasimgs = document.getElementsByTagName('canvas'); | |
| Array.from(canvasimgs).forEach( | |
| function(currentValue, currentIndex) { | |
| // prevent exception if canvas is blank | |
| try { | |
| // create new img element | |
| var img = newDoc.createElement("img"); | |
| img.src = currentValue.toDataURL('image/png'); | |
| img.style = "display: block;margin: auto;"; | |
| img.id = "id" + currentIndex; | |
| // attach img to the document | |
| newDoc.body.appendChild(img); | |
| } catch { | |
| return; | |
| } | |
| }); | |
| // swap document contents | |
| w.document.replaceChild( | |
| w.document.importNode(newDoc.documentElement, true), | |
| w.document.documentElement | |
| ); |
Author
this is JavaScript, you can run in chrome console, with the webpage contains Canvas images.
thanks simon
في الثلاثاء، 2 نوفمبر 2021 في 2:20 ص تمت كتابة ما يلي بواسطة Simon Lee
***@***.***>:
… ***@***.**** commented on this gist.
------------------------------
this is JavaScript, you can run in chrome console, with the webpage
contains Canvas images.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://gist.github.com/cd3ffe980c5393a738226da8cb652c40#gistcomment-3947895>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWJSVS3424PISLOR7DDPIXTUJ4VFZANCNFSM5HECA33A>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
hello brother i need help
في الثلاثاء، 2 نوفمبر 2021 في 6:56 ص تمت كتابة ما يلي بواسطة mohamed
ngah ***@***.***>:
… thanks simon
في الثلاثاء، 2 نوفمبر 2021 في 2:20 ص تمت كتابة ما يلي بواسطة Simon Lee
***@***.***>:
> ***@***.**** commented on this gist.
> ------------------------------
>
> this is JavaScript, you can run in chrome console, with the webpage
> contains Canvas images.
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <https://gist.github.com/cd3ffe980c5393a738226da8cb652c40#gistcomment-3947895>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AWJSVS3424PISLOR7DDPIXTUJ4VFZANCNFSM5HECA33A>
> .
> Triage notifications on the go with GitHub Mobile for iOS
> <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
> or Android
> <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
>
>
hello simon
في الثلاثاء، 2 نوفمبر 2021 في 9:08 ص تمت كتابة ما يلي بواسطة mohamed
ngah ***@***.***>:
… hello brother i need help
في الثلاثاء، 2 نوفمبر 2021 في 6:56 ص تمت كتابة ما يلي بواسطة mohamed
ngah ***@***.***>:
> thanks simon
>
> في الثلاثاء، 2 نوفمبر 2021 في 2:20 ص تمت كتابة ما يلي بواسطة Simon
> Lee ***@***.***>:
>
>> ***@***.**** commented on this gist.
>> ------------------------------
>>
>> this is JavaScript, you can run in chrome console, with the webpage
>> contains Canvas images.
>>
>> —
>> You are receiving this because you commented.
>> Reply to this email directly, view it on GitHub
>> <https://gist.github.com/cd3ffe980c5393a738226da8cb652c40#gistcomment-3947895>,
>> or unsubscribe
>> <https://github.com/notifications/unsubscribe-auth/AWJSVS3424PISLOR7DDPIXTUJ4VFZANCNFSM5HECA33A>
>> .
>> Triage notifications on the go with GitHub Mobile for iOS
>> <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
>> or Android
>> <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
>>
>>
>
Author
please describe your problem.
the script collects 'canvas' tags, then try convert it into images, then returns new html pages with converted.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hello Simon How does this work