Hi, Habr.
Retreat:
In this post you will not find the very pill for all diseases, but there is a solution to the atomic problem, albeit not quite beautiful. The goals of this post are to get more feedback, start a discussion, infect with an idea, push. Although in this case we are talking about VKontakte, I would ask the reader to disengage from this social. network and look at it more globally.
Problem:
VKontakte can hide individual posts and block posts from specific people, groups and applications. But you can not hide posts with unwanted content.
')
I will describe on a simple example:
I subscribe to the music community and I like to periodically update playlists, randomly learn new groups and so on. But I do not like to see the same advertising posts several times a day. With repost, everything is simple: you can block the source. And what about advertising posts on behalf of the community itself? Yes, you can block the community posts in the tape and periodically go for the new music, but here the usability is lost. An example is not the only one. There are many communities and people with interesting posts in the feed, but sometimes, and sometimes quite often, many unwanted posts are sprinkled from them.
From problem to solution:
The choice fell on javascript. A few experiments in the console and the code is ready:
function setWords() { words = prompt('Enter bad words and phrases. Comma separated (,).',localStorage.getItem('bad_words')); if(typeof(words) == 'string') { localStorage.setItem('bad_words',words); } } function hunt() { if( ! localStorage.getItem('bad_words')) { setWords(); return; } textArr = localStorage.getItem('shit_words').split(','); posts = document.getElementsByClassName('feed_row'); for(ii =0; ii<posts.length; ii++) { for(ll = 0; ll<textArr.length; ll++) { if(posts[ii].innerText.search(textArr[ll].trim()) > 0) { thepost = document.getElementsByClassName('feed_row')[ii].children[0]; idToDel = thepost.getAttribute('id').split('post')[1]; delElement = document.getElementById('post_delete'+idToDel); if(delElement) {delElement.click();} break; } } } setTimeout('hunt()',5000); }; hunt(); if( ! document.getElementById('vk_feed_cleaner')) { menuVK=document.getElementById('side_bar').children[0]; a=document.createElement('a'); a.setAttribute('href','javascript:setWords();'); a.innerText = 'Set Bad Words'; li=document.createElement('li'); li.setAttribute('id','vk_feed_cleaner'); li.appendChild(a); menuVK.appendChild(li); }
The principle to ugliness is simple:
Run the script in the console.
When you first start, he will ask for "bad" words or phrases. (comma separator)
Saves words to localStorage.
Every 5 seconds we run through the content of posts: HTML elements with the class “feed_row”
If at least 1 bad word is found in the text of the element, then programmatically click on the HTML element of the post removal.
In the side menu is placed the link: Set Bad Words, by clicking on which you can change the list of bad words.
jsfiddle.net/U2r9k/7 - and here there is a link that you can drag and drop on the bookmarks bar to activate the code by clicking.
Not optimized? Wooden? Not sexy? The main thing that worked, and my problem was solved. I really hope that he will help many people as well as me.
Immediately went to the head thoughts about optimizing the process.
The cons are obvious:
The script requires launching each page opening or reloading.
Large dictionaries will load the browser.
Possible solutions to this problem:
Create browser extensions.
Create an offline application to give access to your account. The application will filter the tape 24 hours a day.
Of course, the second option is better, because One application solves the problem of cross-platform. But the first option also has the right to exist - parental control.
If the offline application can only filter the user's personal tape, then the browser extension will “walk” along with the user. I have children who, for the time being, do not use, but will soon use a computer.
Imagine that an application can develop to such a simple service where there will be an online database of dictionaries / masks by categories (for example: VKontakte 18+, classmates advertising)
And browser extensions that support multiple social services. networks.
Install the extension and select the dictionaries. The child is looking for a video, viewing his news, other people's pages, communities, and the content is run through the filter and unwanted elements are hidden / removed.
A sort of analog AdBlock.
There is another problem - duplicates. I'm not talking about repost, but about cases when the same content is fasting on behalf of a particular community / person. The situation is quite frequent. Perhaps this is an application that preserves a sort of fingerprint of the post in the database "I have already seen it, you can no longer display it." Often, posts are simply copied from each other, and very rarely content is rewritten. By the way, with this application will be solved the problem with repeated advertisements in the tape.
The opinions of habrovchan on this account are interesting.
And finally, a survey on the topic.
PS Perhaps such applications / services already exist, but I have not found such, if anyone knows, share.
All good.