Skip to content

Instantly share code, notes, and snippets.

@jamiephan
Last active December 12, 2024 00:00
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.`)
})())
@hakodev
Copy link

hakodev commented Oct 22, 2024

Could you please adapt this code to claim all free assets on Fab? (That being, Unity, Unreal and UEFN)

https://www.fab.com/megascans-free
All it takes is one click.

@melnation-com
Copy link

Still thanks for all your hardwork, the Claim Megascans Free button was just an afterthought and wouldn't even be born if it weren't for the what I call leet code community and shown it's possible in due time. If it weren't for you, they'll probably chatGPT some PR excuse that all assets were 5-digit GB in size and have to ROI and make it paid if not make it available for free directly.

@melnation-com
Copy link

Downloading a few hours now, ordered a new harddrive to save all the data (must be around 4,5TB; don't know exactly, because it is still running)

@IONADS you estimate 4-5TB for the total based on your ongoing downloads? Or did you only download 4-5TB so far, and still ongoing?

If you downed ~1800 already we can all extrapolate to 18k from that size. So what's the latest figures at your end, so far: how many GB/TB for how many assets, right now? Thank ya, would rather buy a 5TB than a 20TB 😁

Still a better failsafe than ToS'es that they can retroactively change at will like Unity. For my hobby and this quality and this flexible assets, for world building and for peace of mind, it's a small price to pay.

@lilmnm-kamikaze-
Copy link

lilmnm-kamikaze- commented Oct 23, 2024

So will this be updated to add all assets to library on the new fab site for those that didnt see this until it was to late? As if its not in your library you down "own" it even though you clicked the 'Claim Megascans Free button'

@DrakeyB01
Copy link

Didn't think that megascan would peace out today, and I tried the code it doesn't work anymore, either fab is currently adding megascan files into their database cause just a simple search of rock ended with no results or it's probably going to be another money hungry corporate to make us pay for it
image_2024-10-23_112748396

image_2024-10-23_112548899

@romeishka
Copy link

So will this be updated to add all assets to library on the new fab site for those that didnt see this until it was to late? As if its not in your library you down "own" it even though you clicked the 'Claim Megascans Free button'

"Starting right now until the end of 2024, you can claim the entire Megascans library for free ..."

Screenshot 2024-10-23 044634

@rkdms7027
Copy link

스크린샷 2024-10-23 134814
Does anyone know why this is happening? Please help me.....

@nondetect
Copy link

Does anyone know why this is happening? Please help me.....

Because quixel now redirect to fab, and that script didn't work now

@rkdms7027
Copy link

스크린샷 2024-10-23 152314
@nondetect
I tried to download all assets from Megascans but I keep getting an error

@liaoweitian
Copy link

스크린샷 2024-10-23 152314 @nondetect I tried to download all assets from Megascans but I keep getting an error

me too

@hyperion2022
Copy link

All it t

I've seen it, but there are other non-Quixel assets that are free and not purchaseable more than one at a time (and the list isn't even numbered, it just loads more and more assets.

@Jemish1728
Copy link

Hi,

I am getting the below error. Any Help?

Also I'm unable to find the subscribe button.

image

@xtremertx
Copy link

xtremertx commented Oct 23, 2024

Could you please adapt this code to claim all free assets on Fab? (That being, Unity, Unreal and UEFN)

https://www.fab.com/megascans-free All it takes is one click.

There is a few questions we should ALL ask ourselves:

  1. All those Quixel assets you obtain FREE on Fab.com will be obtained under Fab Standart License - what is the difference against Quixel original license (Indie, UE)?

image

  1. Some Quixel assets were discontinued and are NOT available on Fab.com - which ones?
    image

  2. Will this Fab Standart License override original Quixel license..

Note:
I can see some Quixel assets on Fab.com which I have downloaded before and used in my UE projects but I can't see any "acquired" assets by this script there. And I'm afraid that Fab Standart License may have drawbacks..

@xtremertx
Copy link

xtremertx commented Oct 23, 2024

Epic claims you should backup your assets as they don't guarantee you can download them in the future, great corporation indeed..
image

So every user should buy multiple TB's of HDD or has NAS

Also it already happened to me that some asset was having copyright issue and they send me an email paraphrasing it as "Hey it's Epic, you can't use this asset anymore, and we will not return you any money, see ya", seems that seller wasn't changer either, so you can actually sell such assets and no one cares, just beautifull 🌞

@Gitsxouxou
Copy link

Hi all, I've been to late for the process.

I'm actually a super nood in code, I just claim all the library for free https://www.fab.com/megascans-free here.
The thing is that now I also have to update the code to paste in the console within this page https://www.fab.com/sellers/Quixel.

The think is that I can't authentified and a lot of stuff changes and even with ChatGPT or Claude I cant find a way...

Is that readable? Or understandable?

It's also may be too late.

Wish you the best thx(emoji)

@Gitsxouxou
Copy link

Hi all, I've been to late for the process.

I'm actually a super nood in code, I just claim all the library for free https://www.fab.com/megascans-free here. The thing is that now I also have to update the code to paste in the console within this page https://www.fab.com/sellers/Quixel.

The think is that I can't authentified and a lot of stuff changes and even with ChatGPT or Claude I cant find a way...

Is that readable? Or understandable?

It's also may be too late.

Wish you the best thx(emoji)

ok i don't see the discussion up there
FEEL STUPID SORRY

@MatrixServerRV
Copy link

Hi all,

Okay, I claimed these assets from FAB.COM. I can download them from there, but I would still want to use Quixel Bridge.
It seems that even if you have permission from FAB, you cannot export via bridge if you have not purchased assets in the site.
Simply put... you need these assets to be added in the purchase section of your account, so we can use them with the direct exporting through Quixel Bridge (let's say for 3dsMax or any other )

How we can make this workaround and add them in the purchase section, so we can download them later via QX Bridge ?

@wikiti
Copy link

wikiti commented Oct 24, 2024

Hey! Cross posting this in case it might be useful to anyone: I just wrote a script to automatically claim Quixel Megascan resources on FAB: https://gist.github.com/wikiti/f64aa14ee65fd194467d8c8944ed8372

@tgrafk12
Copy link

tgrafk12 commented Oct 29, 2024

Does this still work? If so, great, if not, crap. I JUST started using Quixel about a week ago, and now things wont download. 😭

Im trying to download https://quixel.com/megascans/home?search=FabricPattern&assetId=pgjhtls0 and every time i click download, it just brings me to the homepage of FAB, which, what a fucking release if thats the case. cant even make a proper redirect 😆

If anyone has anything to help me out, thatd be awesome :>

@HarkTu
Copy link

HarkTu commented Oct 29, 2024

Does this still work? If so, great, if not, crap. I JUST started using Quixel about a week ago, and now things wont download. 😭

Im trying to download https://quixel.com/megascans/home?search=FabricPattern&assetId=pgjhtls0 and every time i click download, it just brings me to the homepage of FAB, which, what a fucking release if thats the case. cant even make a proper redirect 😆

If anyone has anything to help me out, thatd be awesome :>

https://gist.github.com/wikiti/f64aa14ee65fd194467d8c8944ed8372/

I use this and it worked

@stoatsnhoney
Copy link

Does this still work? If so, great, if not, crap. I JUST started using Quixel about a week ago, and now things wont download. 😭

Im trying to download https://quixel.com/megascans/home?search=FabricPattern&assetId=pgjhtls0 and every time i click download, it just brings me to the homepage of FAB, which, what a fucking release if thats the case. cant even make a proper redirect 😆

If anyone has anything to help me out, thatd be awesome :>

Not all the Quixel Megascans are on Fab yet. Most items, when opened on Quixel's website, will have a link to its Fab version. But if it just leads you to the homepage that means it's not on Fab yet.

@kaefjke
Copy link

kaefjke commented Nov 7, 2024

Guys! Please help! Script doesn't work! it sad "user is not subscribed to any plan" for all assets, but I already have free plan... dunno what to do! HELP!!!! PLEASE!!!

@scarlet-tobar
Copy link

Guys! Please help! Script doesn't work! it sad "user is not subscribed to any plan" for all assets, but I already have free plan... dunno what to do! HELP!!!! PLEASE!!!

Try using this, it is more recent. Fab is going to be the replacement of Quixel.
https://www.fab.com/megascans-free

@Master3002ruthless
Copy link

ATTENTION!, hurry up, the script is working again!

@scarlet-tobar
Copy link

scarlet-tobar commented Nov 22, 2024 via email

@tgrafk12
Copy link

Does this still work? If so, great, if not, crap. I JUST started using Quixel about a week ago, and now things wont download. 😭

Im trying to download https://quixel.com/megascans/home?search=FabricPattern&assetId=pgjhtls0 and every time i click download, it just brings me to the homepage of FAB, which, what a fucking release if thats the case. cant even make a proper redirect 😆

If anyone has anything to help me out, thatd be awesome :>

I honestly just "acquired" as many Adobe products as I needed via the GenP Reddit. I honestly dont know why Epic is also becoming a bit scummy on the "Fab"sets and not just letting us use the old ones that WERE compatible. Companys just need to stop improving something that works and keep with it. Maybe improve bugs, or ease of use, but not CONSOLIDATING 🙄

@Jemish1728
Copy link

Leave a comment

Markdown is supported

Thanks a lot for informing that. it's working.

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