Last active
May 28, 2020 22:22
-
-
Save yutsuku/6f47a7d5c0e1f6e115e43e08319dfbf0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Allegro.pl - lepsze oceny | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description Usuwa wszystkie oceny sprzedaży które nie mają komentarza i mają wszędzie 5 gwiazdek | |
// @author [email protected] | |
// @match https://allegro.pl/uzytkownik/*/oceny* | |
// @grant none | |
// @run-at document-end | |
// @downloadURL https://gist.github.com/yutsuku/6f47a7d5c0e1f6e115e43e08319dfbf0/raw/d579a82a4f39b276a65958da40053683395d2044/Allegro.pl_-_lepsze_oceny.user.js | |
// @updateURL https://gist.github.com/yutsuku/6f47a7d5c0e1f6e115e43e08319dfbf0/raw/d579a82a4f39b276a65958da40053683395d2044/Allegro.pl_-_lepsze_oceny.user.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// webpack:///src/view/components/RatingList.css | |
// visible | |
let targetNode = document.querySelector('._dc45b_2IjZe'); | |
function clean(node) { | |
// webpack:///src/view/styles/main.css | |
// infoWrapper | |
let starList = node.querySelectorAll('._17qy1'); | |
let rating = 0; | |
starList.forEach(function(substar) { | |
// https://assets.allegrostatic.com/opbox-seller-ratings-list/index-pl-PL_34dcb9b2.js | |
// mIconInformationCommonStarFull | |
rating += substar.querySelectorAll('.i1i7x').length; | |
}); | |
let comment = node.querySelector('[data-role="message-span"]'); | |
if (rating === 15 && | |
comment === null) { | |
node.innerHTML = ''; | |
} | |
} | |
const mutationObserver = new MutationObserver(function(mutations) { | |
mutations.forEach(function(mutation) { | |
if (mutation.type === 'childList' && | |
mutation.addedNodes.length === 1 && | |
mutation.removedNodes.length === 0 && | |
mutation.target === targetNode && | |
mutation.addedNodes[0].tagName === 'DIV' && | |
mutation.addedNodes[0].className === '') { | |
clean(mutation.addedNodes[0]); | |
} | |
}); | |
}); | |
mutationObserver.observe(document.documentElement, { | |
childList: true, | |
subtree: true | |
}); | |
// on-load | |
targetNode.childNodes.forEach(function(node) { | |
clean(node); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment