Skip to content

Instantly share code, notes, and snippets.

@Chuvisco88
Last active July 18, 2025 12:33
Show Gist options
  • Save Chuvisco88/6875ba7cb28467e82dde06fcfc0b1a02 to your computer and use it in GitHub Desktop.
Save Chuvisco88/6875ba7cb28467e82dde06fcfc0b1a02 to your computer and use it in GitHub Desktop.
A small script for getting free stuff from the unity asset store
/*
HOW TO USE
##########
- Go to the unity asset store (https://assetstore.unity.com/)
- Select any category and adapt filters to what you want to get
It is recommended to set the "Hide Purchased Assets" and "Free Assets" to reduce working load.
You might also set other filters like for example only 3D Characters or 4+ star ratings only
- Open up the developer console (normally F12)
- Copy this script to the Console (you might change the consts at the beginning, numbers are in milliseconds)
- Write "redeemAll();" (without the quotes) in the console and hit enter
DISCLAIMER
##########
The script goes through all the assets it can find and tries to add them to your assets.
It automatically accepts the agreement popup, so you must be aware of the agreements.
Also the script seems to be rather flaky.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
const showRedemptions = true;
const showNumberOfRedeemableProductsFoundOnCurrentPage = true;
const showAgreementAccepting = true;
const showMyAssetsOnlyAccepting = true;
const timePerProduct = 5000;
const timeUntilAgreementAcceptance = 1000;
const timeUntilMyAssetsOnly = 2500;
const timeBeforeGoingToNextPage = 10000;
function getAllProductDetails() {
return document.querySelectorAll('div.uty-prod-details');
}
function getAllRedeemableAssets() {
return document.querySelectorAll('button[label="Add to My Assets"]');
}
function getAcceptButton() {
return document.querySelector('button[label="Accept"]');
}
function getAddToMyAssetsOnly() {
return document.querySelector('button[label="Add to my assets only"]');
}
function getNextButton() {
return document.querySelector('button[label="Next"]:not(:disabled)');
}
async function redeemCurrentPage(goToNextPage = false) {
console.log(`[INFO] Searching products on current page`);
const allProductDetails = Array.from(getAllProductDetails());
const detailsOfFreeProducts = allProductDetails.filter(product => product.innerHTML.includes('FREE') && product.innerHTML.includes('Add to My Assets'));
if (showNumberOfRedeemableProductsFoundOnCurrentPage) {
console.log(`[INFO] Found ${detailsOfFreeProducts.length} products to redeem.`);
}
detailsOfFreeProducts.forEach(async (item, index) => {
setTimeout(function() {
const firstTextNode = item.querySelector('a div:first-of-type');
const productName = firstTextNode ? firstTextNode.innerText : 'UNDEFINED';
const addToMyAssetsButton = item.querySelector('button[label="Add to My Assets"]');
if (showRedemptions) {
console.log(`[REDEMPTION] ${index+1}/${detailsOfFreeProducts.length} - ${productName}`);
}
addToMyAssetsButton.click();
setTimeout(function() {
const acceptButton = getAcceptButton();
if (acceptButton) {
if (showAgreementAccepting) {
console.log(`[INFO] Accepting agreement for ${productName}`);
}
acceptButton.click();
}
}, timeUntilAgreementAcceptance);
setTimeout(function() {
const myAssetsOnly = getAddToMyAssetsOnly();
if (myAssetsOnly) {
if (showMyAssetsOnlyAccepting) {
console.log(`[INFO] Adding ${productName} to my assets only`);
}
myAssetsOnly.click();
}
}, timeUntilMyAssetsOnly);
}, index * timePerProduct);
});
setTimeout(function() {
console.log('[INFO] Page should be done by now');
const nextButton = getNextButton();
if (goToNextPage && nextButton) {
console.log('[INFO] Going to next page');
nextButton.click();
setTimeout(function() {
console.log('[INFO] Start redeeming new page');
redeemCurrentPage(goToNextPage);
}, timeBeforeGoingToNextPage);
}
}, detailsOfFreeProducts.length * timePerProduct + timeBeforeGoingToNextPage);
}
async function redeemAll() {
redeemCurrentPage(true);
}
@Chuvisco88
Copy link
Author

In the mean time Unity had adapter their store a bit so this script is not working anymore. Mainly the selector in the getAllProductDetails is not accurate anymore.

@rhenwinch
Copy link

Tweaked your code, thanks (this might loop infinitely if it cant find products anymore):

const showRedemptions = true;
const showNumberOfRedeemableProductsFoundOnCurrentPage = true;
const showAgreementAccepting = true;
const showMyAssetsOnlyAccepting = true;
const timePerProduct = 500;
const timeUntilAgreementAcceptance = 1000;
const timeUntilMyAssetsOnly = 2500;
const timeBeforeGoingToNextPage = 10000;

function getAllProductDetails() {
    return document.querySelectorAll("div._3YDeD");
}

function getNextButton() {
    return document.querySelector('button[label="Next"]:not(:disabled)');
}

function getCookie(name) {
    const value = `; ${document.cookie}`;
    const parts = value.split(`; ${name}=`);
    if (parts.length === 2) return parts.pop().split(';').shift();
}

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

async function redeemCurrentPage(goToNextPage = false) {
    console.log(`[INFO] Searching products on current page`);
    const allProductDetails = Array.from(getAllProductDetails());
    const detailsOfFreeProducts = allProductDetails.filter(product => product.innerHTML.includes('FREE') && product.innerHTML.includes('Add to My Assets'));

    if (showNumberOfRedeemableProductsFoundOnCurrentPage) {
        console.log(`[INFO] Found ${detailsOfFreeProducts.length} products to redeem.`);
    }

    for (let index = 0; index < detailsOfFreeProducts.length; index++) {
        const item = detailsOfFreeProducts[index]
        const firstTextNode = item.querySelector('div[data-test="package-title"]');
        const href = item.querySelectorAll("a")[1].href.split("-");
        const id = href[href.length - 1];
        const productName = firstTextNode ? firstTextNode.innerText : 'UNDEFINED';

        try {
            const r = await fetch("https://assetstore.unity.com/api/graphql", {
                "headers": {
                    "operations": "AddToDownload",
                    "x-csrf-token": getCookie('_csrf'),
                    "x-requested-with": "XMLHttpRequest",
                    "x-source": "storefront, storefront"
                },
                "body": `{\"query\":\"mutation AddToDownload($id: String!) {\\n  addToDownload(id: $id) {\\n    id\\n    userOverview {\\n      lastDownloadAt: last_downloaded_at\\n      __typename\\n    }\\n    userEntitlement {\\n      id\\n      orderId\\n      grantTime\\n      __typename\\n    }\\n    __typename\\n  }\\n}\\n\",\"variables\":{\"id\":\"${id}\"},\"operationName\":\"AddToDownload\"}`,
                "method": "POST",
            });

            if (showRedemptions && r.ok) {
                console.log(`[REDEEMED] ${index+1}/${detailsOfFreeProducts.length} - ${productName} (${id})`);
            }
        } catch (err) {
            console.error(err);
        }

        await sleep(timePerProduct);
    }

    console.log('[INFO] Page should be done by now');
    const nextButton = getNextButton();

    if (goToNextPage && nextButton) {
        console.log('[INFO] Going to next page');
        nextButton.click();

        while (getAllProductDetails().length <= 0) await sleep(timeBeforeGoingToNextPage);

        console.log('[INFO] Start redeeming new page');
        redeemCurrentPage(goToNextPage);
    }
}

async function redeemAll() {
    redeemCurrentPage(true);
}

@SYRIANCJ
Copy link

can you please make the script to add alle the free items available on fab.com

@Chuvisco88
Copy link
Author

can you please make the script to add alle the free items available on fab.com

@SYRIANCJ I don't know fab.com and I do not intend to expand this script in the near or prolonged feature.
Potentially the structure of fab.com is different, so it would need its own strategy for going through it.
For now I do not intend to adapt this any further, please feel free to copy the script and create your own gist with the according adaptations.

@SYRIANCJ
Copy link

Fab.com is from epic games but has unity assets in it too, I'm not good at coding yet to make my own script, but thanks for the unity script :)

@Wart050
Copy link

Wart050 commented Dec 22, 2024

Hey just letting you know that the fab.com script you are looking for can be found right here: https://gist.github.com/wikiti/f64aa14ee65fd194467d8c8944ed8372

@SYRIANCJ
Copy link

I don't mean this script, I mean one which can add everything is free, whatever that is.

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