Greasy Fork镜像 还支持 简体中文。

canvas screenshot to tga

useful for io games like woomy-arras.io (press [:])

目前為 2021-04-04 提交的版本,檢視 最新版本

// ==UserScript==
// @name        canvas screenshot to tga
// @namespace   http://bzzzzdzzzz.blogspot.com/
// @description useful for io games like woomy-arras.io (press [:])
// @author      BZZZZ
// @include     *
// @version     0.1
// @grant       none
// @run-at      document-end
// ==/UserScript==

(function(){
var a=document.createElement("div");
a.setAttribute('onclick','document.getElementsByTagName("body")[0].addEventListener("keyup",new Function("evnt",'+JSON.stringify(
	'if(evnt.code!="Semicolon")return;'+
	'var i=document.getElementsByTagName("canvas")[0],img=i.getContext("2d").getImageData(0,0,i.width,i.height),'+
	'w=img.width,h=img.height,raw=img.data,i2=raw.length,tga=new Uint8Array(18+i2);'+
	'tga[2]=2;'+
	'tga[12]=w&255;'+
	'tga[13]=w>>8;'+
	'tga[14]=h&255;'+
	'tga[15]=h>>8;'+
	'tga[16]=32;'+
	'i=18;'+
	'var w4=w*4,end,i3;'+
	'while(0<i2){'+
		'end=i+w4;'+
		'i2-=w4;'+
		'i3=i2;'+
		'while(i<end){'+
			'tga[2+i]=raw[i3++];'+
			'tga[1+i]=raw[i3++];'+
			'tga[i]=raw[i3++];'+
			'tga[3+i]=raw[i3++];'+
			'i+=4;'+			
		'}'+
	'}'+
	'raw=null;'+
	'img=null;'+
	'i=document.createElement("a");'+
	'i.href=URL.createObjectURL(new Blob([tga],{"type":"image/x-targa"}));'+
	'tga=null;'+
	'i.download="shot.tga";'+
	'evnt.target.appendChild(i);'+
	'i.click();'+
	'evnt.target.removeChild(i);'+
	'URL.revokeObjectURL(i.href);'
)+'),false);');
a.click();
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址