TurboSquid Paid Asset Tile Remover In Free Sections

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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);
  }
})();