GM_html2canvas

由于原版的html2canvas在对跨域图片获取上总是失败的问题,将跨域改为通过GM_xmlhttpRequest获取

As of 2024-01-06. See the latest version.

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyfork.org/scripts/456607/1307370/GM_html2canvas.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

Author
WhiteSevs
Version
0.0.1.20230912061525
Created
2022-12-15
Updated
2024-01-06
Size
413 KB
License
N/A

将跨域改为通过GM_xmlhttpRequest获取

介绍

# 我的设置如下
let options = {
    allowTaint: true,
    logging: true,
    useCORS: true,

}
html2canvas(document.documentElement, options ).then( canvas =>{
  var base64Image = canvas.toDataURL("image/png");

})

如果是自己使用webview定义的GM_xmlhttpRequest,可在onload回调参数中新增一个responseBase64用于图片的base64获取