tensor.art profile download

script for tensor.ai profile downloads

As of 09. 09. 2025. See the latest version.

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!)

// ==UserScript==
// @name         tensor.art profile download
// @namespace    http://tampermonkey.net/
// @version      2025-07-27
// @description  script for tensor.ai profile downloads
// @author       user
// @match        https://tensor.art/u/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tensor.art
// @grant        GM_download
// @grant        GM.download
// @grant        GM_xmlhttpRequest
// @grant        GM.xmlHttpRequest
// @connect      *
// @license MIT 
// ==/UserScript==
//https://api.tensor.art/community-web/v1/post/list
/* eslint-disable */
// eslint-disable-line
// eslint-disable-next-line(function() {
    'use strict';
function doc_keyUp(e) {
  switch(e.keyCode)
  {
  case 220: //\
    console.log('starting');
    dlimages(false);
    break;
  case 221: //]
    console.log('starting');
    dlimages(true);
    break;
   default:
     break;
  }
}
document.addEventListener('keyup', doc_keyUp, false);

function getCookie(name) {
  const nameEQ = name + "=";
  const ca = document.cookie.split(';');

  for (let i = 0; i < ca.length; i++) {
    let c = ca[i];

    while (c.charAt(0) === ' ') {
      c = c.substring(1, c.length);
    }
    if (c.indexOf(nameEQ) === 0) {
      return decodeURIComponent(c.substring(nameEQ.length, c.length));
    }
  }
  return null;
}
async function dlimages(onePage) {
    const token = getCookie('ta_token_prod');
    console.log('token'+token);
	let cursor = 0;
	let images = []

	const currentURL = window.location.href.split('/');
	const userid = currentURL[currentURL.length-1];
    let result;

	do {
		const r = await GM.xmlHttpRequest ({
		  method: "POST",
		  url: "https://api.tensor.art/community-web/v1/post/list",
		  headers: {
			"User-Agent": "yo-momma",
			"Accept": "*/*",
			"Accept-Language": "en-US,en;q=0.5",
			"Content-Type": "application/json",
			"X-Request-Sign": "YTA3YjI1ZWY1YjFjNGE4NmU1ZjIyNDI4ZTI4Zjk1MWE3ZmE4ZDI1MzQwZTgyOTAzMmIyYzUyODQ2OTZlZDZlNA==",
			"X-Request-Timestamp": "1754100477114",
			"X-Request-Package-Sign-Version": "0.0.1",
			"X-Request-Sign-Version": "v1",
			"X-Request-Sign-Type": "HMAC_SHA256",
			"X-Request-Package-Id": "3000",
			"Sec-Fetch-Dest": "empty",
			"Sec-Fetch-Mode": "cors",
			"Sec-Fetch-Site": "same-site",
			"x-echoing-env": "",
			"Authorization": "Bearer "+token
		  },
		  data: "{\"cursor\":\""+cursor+"\",\"filter\":{},\"size\":\"40\",\"userId\":\""+ userid +"\",\"sort\":\"NEWEST\",\"visibility\":\"ALL\"}"
		});
		console.log(r.responseText);
		result = JSON.parse(r.responseText);
        console.log(result.data.items);
		result.data.items.forEach(post=>{
			post.images.forEach(image=>{
				images.push(image);
			})
		});
		cursor = result.data.cursor;
	} while(result.data.items.length&&!onePage);

    console.log(images);
    dlimages(images);

async function dlimages(images) {
   let currentDownloads = 0;
   while (images.length > 0) {
      if (currentDownloads > 5) {
         await sleep(200);
         continue;
      }

      var item = images.shift();

      (function(_item) {
          const split = _item.url.split('.');
          const dl = {
            url: _item.url,
            name: userid+'/'+_item.id+'.'+split[split.length-1],
            saveAs: false,
            conflictAction: 'overwrite',
            onerror: function(error) {
               queue.unshift(_item);
               currentDownloads--;
            },
            onload: function() {
                const blob = new Blob([JSON.stringify(_item)], { type: 'text/plain' });
                const url = URL.createObjectURL(blob);

                GM_download({
                    url: url,
                    name: userid+'/'+_item.id+'.json',
                    saveAs: false, // Prompts the user to choose a save location
                    conflictAction: 'overwrite',
                });
                currentDownloads--;
            }
         };
          console.log(dl);
         GM_download(dl);

         currentDownloads++;
      })(item);
   }
};

function sleep(ms) {
   return new Promise(resolve => setTimeout(resolve, ms));
}
}