Skip to content

Instantly share code, notes, and snippets.

@jamiephan
Last active October 3, 2024 20:24
Show Gist options
  • Save jamiephan/0c04986c7f2e62d5c87c4e8c8ce115fc to your computer and use it in GitHub Desktop.
Save jamiephan/0c04986c7f2e62d5c87c4e8c8ce115fc to your computer and use it in GitHub Desktop.
A script to automatically add ALL items to your account in quixel

Script to add all items from quixel

As quixel is being removed, all items are free to aquire. This script is to automate the process to add items to your account (As of writing, a total of 18874 items)

Note: This script only tested in the latest version of Chrome.

How to use

  1. Copy the script from below (run.js)
  2. Login into https://quixel.com
  3. Go to https://quixel.com/megascans/collections
  4. Open devtools (F12) -> Go to "Console" tab
  5. Paste in the script and press Enter.
  6. A dialog should popup confirming the execution, click "OK"
  7. Sit back and wait

Common issues

  • Getting "Forbidden" error. (Even after refresh, the whole page just shows "Forbidden")
    • There is a chance that the API adding too fast and you hit the rate limit of the API. (My testing is around after 10 pages, so ~10k items).
    • Wait after ~10-20 minutes and continue. See Common Fixes -> Restart script to continue the execution after you can load https://quixel.com.
  • The script seems to be paused/hang
    • It could be too much logging going it. Try monitor the script, if it says "END PAGE X", note the page number down (in case need restart) and clear the console by clicking the "🚫" icon in devtools.
    • See Common Fixes -> Restart script for fixing.
  • Getting the error **UNABLE TO ADD ITEM**
    • There should have the error message shown in ( ). If it is user already owns specified asset at a higher or equal resolution, then its already in your account.
  • Getting the error cannot find authentication token. Please login again
    • Clear browser cookies and re-login quixel again. Try just simply add 1 item manully. If it success, then see Common Fixes -> Restart script for continue the execution.

Common Fixes

Restart Script

  1. Note which page it was running
  2. Copy the run.js script
  3. Update the startPage = 0 on the first line to startPage = 10 (assuming page 10 was hanged)

Change Log

  1. Initial Script launch
  2. Update to clear logs to reduce chance of hanging
  3. [CURRENT] Skip adding items that already was acquired. Reduced logs. Added more info after script completion to show purchased item count. Due to now skipping purchased items, you technically don't need to specify the startPage anymore.
((async (startPage = 0, autoClearConsole = true) => {
const getCookie = (name) => {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
}
const callCacheApi = async (params = {}) => {
const defaultParams = {
page: 0,
maxValuesPerFacet: 1000,
hitsPerPage: 1000,
attributesToRetrieve: ["id", "name"].join(",")
}
const response = await fetch("https://proxy-algolia-prod.quixel.com/algolia/cache", {
"headers": {
"x-api-key": "2Zg8!d2WAHIUW?pCO28cVjfOt9seOWPx@2j"
},
"body": JSON.stringify({
url: "https://6UJ1I5A072-2.algolianet.com/1/indexes/assets/query?x-algolia-application-id=6UJ1I5A072&x-algolia-api-key=e93907f4f65fb1d9f813957bdc344892",
params: new URLSearchParams({ ...defaultParams, ...params }).toString()
}),
"method": "POST",
})
return await response.json()
}
const callAcl = async ({ id, name }) => {
const response = await fetch("https://quixel.com/v1/acl", {
"headers": {
"authorization": "Bearer " + authToken,
"content-type": "application/json;charset=UTF-8",
},
"body": JSON.stringify({ assetID: id }),
"method": "POST",
});
const json = await response.json()
if (json?.isError) {
console.error(` --> **UNABLE TO ADD ITEM** Item ${id} | ${name} (${json?.msg})`)
} else {
console.log(` --> ADDED ITEM Item ${id} | ${name}`)
}
}
const callAcquired = async () => {
const response = await fetch("https://quixel.com/v1/assets/acquired", {
"headers": {
"authorization": "Bearer " + authToken,
"content-type": "application/json;charset=UTF-8",
},
"method": "GET",
});
return await response.json()
}
// 1. Check token exist, quixel API needs it
console.log("-> Checking Auth API Token...")
let authToken = ""
try {
const authCookie = getCookie("auth") ?? "{}"
authToken = JSON.parse(decodeURIComponent(authCookie))?.token
if (!authToken) {
return console.error("-> Error: cannot find authentication token. Please login again.")
}
} catch (_) {
return console.error("-> Error: cannot find authentication token. Please login again.")
}
// 2. Get all currently acquired items
console.log("-> Get Acquired Items...")
const acquiredItems = (await callAcquired()).map(a => a.assetID)
// 3. Get total count of items
console.log("-> Getting Total Number of Pages....")
const { nbPages: totalPages, hitsPerPage: itemsPerPage, nbHits: totalItems } = await callCacheApi()
console.log("-> ==============================================")
console.log(`-> Total # of items: ${totalItems}`)
console.log(`-> ${totalPages} total pages with ${itemsPerPage} per page`)
console.log(`-> Total Items to add: ${(totalItems - acquiredItems.length)}.`)
console.log("-> ==============================================")
if (!confirm(`Click OK to start adding ${(totalItems - acquiredItems.length)} items in your account.`)) return
// Loop
for (let pageIdx = startPage || 0; pageIdx < totalPages; pageIdx++) {
console.log(`-> ======================= PAGE ${pageIdx + 1}/${totalPages} START =======================`)
console.log("-> Getting Items from page " + (pageIdx + 1) + " ...")
const { hits: items } = await callCacheApi({ page: pageIdx })
console.log("-> Adding non-acquired items...")
// Filter out owned items
const unownedItems = items.filter(i => !acquiredItems.includes(i.id))
const aclPromises = unownedItems.map(callAcl)
await Promise.all(aclPromises)
console.log(`-> ======================= PAGE ${pageIdx + 1}/${totalPages} COMPLETED =======================`)
if (autoClearConsole) console.clear() // Fix the issue that too much log hangs the console. Set autoClearConsole = false to keep the logs
}
console.log("-> Getting new acquired info...")
// Get acquired items again
const newItemsAcquired = (await callAcquired()).length
const newTotalCount = (await callCacheApi()).nbHits
console.log(`-> Completed. Your account now have a total of ${newItemsAcquired} out of ${newTotalCount} items.`)
alert(`-> Your account now have a total of ${newItemsAcquired} out of ${newTotalCount} items.\n\nIf you find some items missing, try refresh the page and run the script again.`)
})())
@mbonne
Copy link

mbonne commented Sep 29, 2024

Noice

@vash-wood
Copy link

thank you ^^b

@mderis
Copy link

mderis commented Sep 29, 2024

I am getting this error for almost all the items:
**UNABLE TO ADD ITEM** Item wgssfig | Forest Rock Slab (user is not subscribed to any plan)
Any solutions?

@Sheetosshouar
Copy link

--> 987/18874 UNABLE TO ADD ITEM Item xbnedjk | Quarry Slate Ground Gravel Coarse 04 (user does not have enough quota)

Any solutions?

@ritinfosec01
Copy link

worked for me but it only added 8k assets

@Lucaswatt
Copy link

legend

@DamienBlackwood
Copy link

All im getting is user is not subscribed to any plan, Im trying this on an alt, and it worked previously on my main account, so maybe its patched.

@BarrettGaertner
Copy link

Thanks! Also

image

lol

@DamienBlackwood
Copy link

Thanks! Also
lol

How lol?

@zukyi1
Copy link

zukyi1 commented Sep 30, 2024

I was able to add all the assets on the quixel page but when I enter brige in unreal it appears purchased but I have to subscribe when I am already subscribed
any solution?

@qsedftghk
Copy link

jamiephan it's wonderful. thank you!

@wysiwyg-git
Copy link

image

Any ideas?

@ajju-create
Copy link

ajju-create commented Sep 30, 2024

Thankyou so much, I used Firefox and it worked fine, Whenever it was hanging, I refresh the page and run the script again, it adds remaining assets. Many thanks

@DamienBlackwood
Copy link

nevermind fixed now

@romeishka
Copy link

Any ideas?

Just Log-in with Epic account which allows you to get those assets for free, if you don't have access to get assets for free this script can't add it to your megascan account...

@FoundYourName
Copy link

谢谢

@SaraCastro132
Copy link

For people who have this problem
" user does not have enough quota " ooo " user is not subscribed to any plan "
you have to go to Home then choose an object you want, open it and click subscribe and there you will be asked to activate the free subscription
xoxo
@wysiwyg-git
@mderis
@Sheetosshouar

@guisantos
Copy link

For people who have this problem " user does not have enough quota " ooo " user is not subscribed to any plan " you have to go to Home then choose an object you want, open it and click subscribe and there you will be asked to activate the free subscription xoxo @wysiwyg-git @mderis @Sheetosshouar

Worked for me, thanks!

@Adam1590
Copy link

Adam1590 commented Oct 1, 2024

Screenshot 2024-09-24 144232 guys i haveee this problem plz help

The answer what to do is at the end of text on your pic...

Screenshot 2024-09-24 144142

Снимок экрана 2024-10-01 180744

help pls

@Adam1590
Copy link

Adam1590 commented Oct 1, 2024

Screenshot 2024-09-24 144232 guys i haveee this problem plz help

The answer what to do is at the end of text on your pic...

Screenshot 2024-09-24 144142

Screenshot 2024-09-24 144232 guys i haveee this problem plz help

The answer what to do is at the end of text on your pic...

Screenshot 2024-09-24 144142

скриншот вообще не открывается как я только не пробовал

@TheGamerX20
Copy link

Thanks a lot for this!

@Crisium
Copy link

Crisium commented Oct 2, 2024

don't use, now I get a message 403 Forbidden .... thanks for blacklisting me with your script

@romeishka
Copy link

romeishka commented Oct 2, 2024

don't use, now I get a message 403 Forbidden .... thanks for blacklisting me with your script

Do you even read description? 🤦‍♂️🤦‍♂️🤦‍♂️

Screenshot 2024-09-25 180918

Or like someone did write here as well try to use VPN if you don't want to wait...

@fatiherkinay
Copy link

Thanks a lot. It worked for me :) It only stuck a few times and I refreshed the page and ran it again and it all worked.

@Daidalosz
Copy link

Thank you!!!

@okaysokayso
Copy link

may the pixel gods turn your 2k textures into 8k textures but weigh as light as 512's
Thanks for this!!

@BrunoCaxito
Copy link

Thank you very much!!!

@lavinia103
Copy link

another workaround for no VPN is to connect to your mobile hotspot rather than your home WiFi, aka changing your IP, gets rid of 403 Forbidden

@repsejnworb
Copy link

Abosolute chad!

I somehow ended up with +2 assets 😆 so some fun bug.

Can't state enough how grateful I am for you sharing this

@infernocloud
Copy link

infernocloud commented Oct 3, 2024

In my fork I've added a 10 second pause between processing each page and this successfully avoided Quixel's API rate limiting and the script ran in minutes without any extra manual handling. Feel free to pull in the changes!

https://gist.github.com/infernocloud/5f20a8e85070ccfeda3da14cf7f9b6c6

Thank you for writing this script, this is awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment