Created
November 25, 2014 23:07
-
-
Save CezaryDanielNowak/e8ce8a54d83f5e477ba4 to your computer and use it in GitHub Desktop.
Greasemonkey: Wykluczanie samochodów z wyników wyszukiwania otomoto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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