NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name VK.com count tags
// @namespace derevnia
// @author vk.com/derevnia
// @description Подсчёт тегов на странице
// @version 0.1.1
// @updateURL https://openuserjs.org/install/derevnia/VK.com_count_tags.user.js
// @downloadURL https://openuserjs.org/install/derevnia/VK.com_count_tags.user.js
// @include *://vk.com/search*
// @grant none
// ==/UserScript==
window.onload = function () {
//console.debug()
function getCookie(tag) {// получение cookie
var matches = document.cookie.match(new RegExp(
"(?:^|; )" + tag.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
));
return matches ? decodeURIComponent(matches[1]) : undefined;
}
var count_day_var = getCookie('tag');
var count_d = parseInt(count_day_var, 10);// сбой cookie
var count = 0;
function delCookie(name) {// удаление cookie
document.cookie = name + "=" + "; expires=Thu, 01 Jan 1970 00:00:01 GMT";
}
function setCookie(tag) {// установка cookie
now = new Date();
var date = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59);
document.cookie = "tag=" + escape(tag) + "; expires=" + date.toUTCString();
}
document.getElementById("stl_bg")
.innerHTML += "<br /><div style='display:inline;padding:0 10px;font-weight:bold;color:#45688e'>Now: <div id='count_ad' style='display:inline'>" + count + "</div></div><br />";
console.debug('#'.codePointAt(0));
var li = document.getElementsByClassName('wall_post_text');
var GetSearch = document.getElementById('search_query').value;
// GetSearch=GetSearch.replace(/[^A-zА-яЁё_#]/g, '');//оставить только буквы и знак #
var patt = new RegExp(''+GetSearch+'', 'i');
var count_ad = document.getElementById("count_ad");
console.debug(patt);
var clickEvent = new MouseEvent("click");
function feed() {
// console.debug(window.location.pathname);
if (window.location.pathname == "/search") {
var refresh = document.getElementById("show_more_link");
if (document.getElementById("show_more_link"))
{
if (refresh.getAttribute('style') != 'display: none' && refresh.getAttribute('style') != 'display: none;')
{
refresh.dispatchEvent(clickEvent);
}
}
// for (var i = 0; i < li.length; i++) {
// var pureTEXT=li[i].innerHTML.replace(/<[^>]*>/g, "");//вырезать html теги
// pureTEXT=pureTEXT.replace(/[^A-zА-яЁё_# ]/g, '');//оставить только буквы и знак # и пробел
// if (pureTEXT.indexOf('#')>0)
// {
// pureTEXT=pureTEXT.slice(pureTEXT.indexOf('#'));
// }
// if (patt.test(pureTEXT) === true) {
for (var i = 0; i < li.length; i++) {
if (li[i].getAttribute('d') != 'true') {
li[i].setAttribute('d', 'true');
li[i].parentNode.querySelector("div.post_actions_wrap>div.post_actions>div");
count++;
}
// }
}
// обновление счетчиков
count_ad
.innerHTML = count;
// end обновление
return count;
}
}
setInterval(feed, 1000);
}