NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name VK.com hide view posts
// @namespace s00d
// @author https://vk.com/id6460312
// @description Скрывает просмотренные посты (vkontakte) (without jquery)
// @version 1.0
// @include *://vk.com/*
// @grant none
// @license MIT
// @copyright 2018, s00d (https://openuserjs.org/users/s00d)
// ==/UserScript==
var load = false;
function clean() {// отчистка
var list = document.getElementsByClassName('_post');
for(var i in list)
try{
if(list[i].getBoundingClientRect().top < -100) {list[i].style.display = 'none'}
} catch(e){
};
}
function scrollToTop() {// скрол
window.scroll({
top: 0,
left: 0,
//behavior: 'smooth'
});
}
window.addEventListener("load", function(){
console.log('[vk post clean] add button')
if(load) return;
load = true;
var button = document.createElement("button");
button.innerHTML = "clear";
button.style.opacity = 0.5;
button.style.position = "absolute";
button.style.right = '200px';
button.style.top = '15px';
// 2. Append somewhere
var pos = document.getElementById("page_header_wrap");
pos.appendChild(button);
button.addEventListener ("click", function() {
clean();
scrollToTop();
});
});