Skip to content

Instantly share code, notes, and snippets.

@CezaryDanielNowak
Created November 25, 2014 23:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CezaryDanielNowak/e8ce8a54d83f5e477ba4 to your computer and use it in GitHub Desktop.
Save CezaryDanielNowak/e8ce8a54d83f5e477ba4 to your computer and use it in GitHub Desktop.
Greasemonkey: Wykluczanie samochodów z wyników wyszukiwania otomoto
// ==UserScript==
// @name Wyklucz autka
// @namespace Autocentrum
// @include http://otomoto.pl/*
// @version 1
// @grant none
var fc = function(event) {
// funkcja nadaje opacity 0.1 każdemu samochodowi z listy,
// który jest wypisany w liście poniżej
var cars = document.querySelectorAll('.om-list-item');
var car,
headerTxt,
i;
var has = function(what) {
return headerTxt.indexOf(what) >= 0
};
for(i=cars.length-1; i>=0; i--) {
car = cars[i];
headerTxt = car.querySelector('h3').innerHTML.toLowerCase();
if(
has('nissan') ||
has('renault') ||
has('jeep') ||
has('volkswagen') ||
has('alfa') ||
has('peugeot') ||
has('ford galaxy') ||
has('land rover') ||
has('chrysler') ||
has('fiat') ||
has('citroën') ||
has('citroen') ||
has('aixam') ||
has('opel vectra') ||
has('smart fortwo') ||
has('hyundai sonata') ||
has('opel zafira') ||
has('dodge grand')
) {
car.style.opacity = '.1';
}
}
};
var timeout;
document.addEventListener("DOMContentLoaded", function() {
document
.getElementById('om-list-items')
.addEventListener('DOMSubtreeModified', function() {
clearTimeout(timeout);
timeout = setTimeout(fc, 250);
});
fc();
});
// ==/UserScript==
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment