TurboSquid Paid Asset Tile Remover In Free Sections

Removes the paid asset tiles when the free tag is selected on TurboSquid

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         TurboSquid Paid Asset Tile Remover In Free Sections
// @namespace    https://www.turbosquid.com
// @version      1.0
// @license      MIT
// @description  Removes the paid asset tiles when the free tag is selected on TurboSquid
// @author       slysnake96 & ChatGPT
// @match        https://www.turbosquid.com/*
// @grant        none
// ==/UserScript==

(function() {
  'use strict';

  let removalExecuted = false;

  // Function to remove asset tiles
  function removeAssetTiles() {
    if (removalExecuted) {
      return; // Exit if removal has already been executed
    }

    console.log('Removing asset tiles...');

    // Get all the asset tiles on the webpage
    const assetTiles = document.querySelectorAll('div.search-lab.AssetTile-md.tile-large');

    // Loop through the asset tiles
    assetTiles.forEach(tile => {
      const priceElement = tile.querySelector('label.lightPrice');
      const priceText = priceElement ? priceElement.textContent.trim() : '';

      // Check if the tile represents a paid asset
      if (priceText !== 'Free' && priceText !== '$0') {
        // Remove the asset tile
        tile.remove();
        console.log('Asset tile removed:', tile);
      }
    });

    console.log('Asset tile removal complete.');
    removalExecuted = true;
  }

  // Check if the URL contains the word "free"
  if (window.location.href.includes('free')) {
    // Monitor for new content loaded via AJAX
    const observer = new MutationObserver(removeAssetTiles);
    const config = { childList: true, subtree: true };
    observer.observe(document.body, config);
    console.log('Observer started.');

    // Check and remove asset tiles at intervals
    const interval = setInterval(() => {
      if (document.readyState === 'complete') {
        removeAssetTiles();
        clearInterval(interval);
        console.log('Asset tile removal executed on page load.');
      }
    }, 1000);
  }
})();