Olx

Remove todas as cidades que não são BH

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Olx
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Remove todas as cidades que não são BH
// @author       Marcello Cavazza
// @match        https://www.olx.com.br/*
// @icon         https://upload.wikimedia.org/wikipedia/commons/b/b3/Logo_olx.png
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var button = document.createElement('button');

    button.textContent = 'Remover cidades';
    button.style.zIndex = '99999999';
    button.style.position = 'fixed';
    button.style.top = '20px';
    button.style.left = '20px';
    button.style.background = '#007bff';
    button.style.color = '#fff';
    button.style.border = 'none';
    button.style.padding = '10px 20px';
    button.style.borderRadius = '5px';
    button.style.cursor = 'pointer';

    document.body.appendChild(button);

    button.addEventListener('click', function () {
    console.log('starting olx cleaning script')
      const lojasGrid = document.getElementsByClassName('AdListing_gridLayout__DTjHC');

      lojasGrid[0].childNodes.forEach((loja) => {
          var lojaLocalizacao = loja.textContent.trim();
          
          if (lojaLocalizacao.toLowerCase().replaceAll(" ", "").indexOf("belohorizonte") == -1)
          {
            loja.style.display = 'none'
          }
      });
    console.log('ending olx cleaning script')
    });
})();