Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name WykopCrapFilter
- // @version 1
- // @grant Melcma
- // ==/UserScript==
- // config
- // types: warning/accepted/banned
- var markedUrls = [
- {
- url: 'wp.pl',
- type: 'warning'
- },
- {
- url: 'liveleak.com',
- type: 'accepted'
- },
- {
- url: 'youtube.com',
- type: 'accepted'
- },
- {
- url: 'youtu.be',
- type: 'accepted'
- },
- {
- url: 'polsatnews.pl',
- type: 'banned'
- }
- ]
- var colourMap = {
- night: {
- warning: '#3c2c2c',
- accepted: '#2c3c2c'
- },
- day: {
- warning: '#ffdddd',
- accepted: '#aaffaa'
- }
- }
- // logic
- var theme = document.getElementsByTagName('body')[0].classList.contains('night') ? 'night' : 'light';
- var container = document.getElementById('itemsStream');
- var posts = container.getElementsByClassName('link');
- Array.prototype.forEach.call(posts, function(post) {
- var source = post.querySelector('.tag.create a');
- if (!source) return;
- markedUrls.forEach(function(mark) {
- if (source.href.indexOf(mark.url) > -1) {
- if (mark.type === 'banned') {
- post.style.display = 'none';
- } else {
- post.style.backgroundColor = colourMap[theme][mark.type];
- }
- }
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement