
A simple VK tape filter by bad words and who it might become
Hi, Habr.
In this post you will not find the same pill for all diseases, but there is a solution to the atomic problem, albeit not entirely beautiful. The purpose of this post is 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 abstract from this social. network and look at it more globally.
VKontakte has the ability to hide single posts and block the display of posts from specific people, groups and applications. But you can’t hide posts with inappropriate content.
I’m subscribed to the music community and I like to periodically update playlists, randomly learn new groups, etc. But I do not like to see the same advertising posts several times a day. With reposts, everything is simple: you can block the source. But what about advertising posts on behalf of the community itself? Yes, you can block community posts in the stream and periodically stop by for new music, but here the usability is lost. An example is far from the only one. There are many communities and people with interesting posts in the feed, but sometimes, and at times often a lot of unwanted posts are sprinkled from them.
The choice fell on javascript. A little experimentation in the console and the code is ready:
Run the script in the console.
At the first start, he will ask you to enter "bad" words or phrases. (comma delimiter)
Stores words in localStorage.
Every 5 seconds we go through the contents of the posts: HTML elements with the class “feed_row”
If at least 1 bad word is found in the element text, then programmatically click on the HTML element for deleting the post.
A link is placed in the side menu: Set Bad Words, by clicking on which you can change the list of bad words.
jsfiddle.net/U2r9k/7 - and there’s a link by dragging it to the bookmarks bar, you can activate the code by click.
Not optimized? Wooden? Not sexy? The main thing that worked, and my problem was resolved. I really hope that he will help many people as well as me.
Immediately went into my head thoughts about optimizing the process.
The script requires launching every opening or reloading of the page.
Large dictionaries will load the browser.
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 cross-platform problem. But the first option also has a right to exist - parental control.
If the offline application can only filter the user's personal feed, then the browser extension will “walk” with the user. I have children who have not yet used, but will soon be using a computer.
Imagine that the application can develop to such a simple service, where there will be an online database of dictionaries / masks by category (for example: VK 18+, classmates advertising)
And browser extensions that support multiple social. networks.
Install the extension and select dictionaries. The child searches for videos, views his news, other people's pages, communities, and the content is run through the filter and unwanted elements are hidden / deleted.
A sort of AdBlock analogue.
There is another problem - duplicates. I'm not talking about reposts, but about cases when the same content is posted on behalf of a particular community / person. The situation is quite common. Perhaps this is an application that saves a kind of fingerprint of a post to the database "I have already seen this, you can no longer display it." Often posts are simply copied from each other, and very rarely content is copied. By the way, with such an application, the problem with repeated advertising posts in the feed will be solved.
The opinions of the Khabrovsk residents on this matter are interesting.
And finally, a survey on the topic.
PS Perhaps such applications / services already exist, but I did not find such, if anyone knows, share it.
Good to all.
Retreat:
In this post you will not find the same pill for all diseases, but there is a solution to the atomic problem, albeit not entirely beautiful. The purpose of this post is 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 abstract from this social. network and look at it more globally.
Problem:
VKontakte has the ability to hide single posts and block the display of posts from specific people, groups and applications. But you can’t hide posts with inappropriate content.
I will describe it with a simple example:
I’m subscribed to the music community and I like to periodically update playlists, randomly learn new groups, etc. But I do not like to see the same advertising posts several times a day. With reposts, everything is simple: you can block the source. But what about advertising posts on behalf of the community itself? Yes, you can block community posts in the stream and periodically stop by for new music, but here the usability is lost. An example is far from the only one. There are many communities and people with interesting posts in the feed, but sometimes, and at times often a lot of unwanted posts are sprinkled from them.
From problem to solution:
The choice fell on javascript. A little experimentation 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 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 disgrace is simple:
Run the script in the console.
At the first start, he will ask you to enter "bad" words or phrases. (comma delimiter)
Stores words in localStorage.
Every 5 seconds we go through the contents of the posts: HTML elements with the class “feed_row”
If at least 1 bad word is found in the element text, then programmatically click on the HTML element for deleting the post.
A link is placed in the side menu: Set Bad Words, by clicking on which you can change the list of bad words.
jsfiddle.net/U2r9k/7 - and there’s a link by dragging it to the bookmarks bar, you can activate the code by click.
Not optimized? Wooden? Not sexy? The main thing that worked, and my problem was resolved. I really hope that he will help many people as well as me.
Immediately went into my head thoughts about optimizing the process.
Cons are obvious:
The script requires launching every opening or reloading of the page.
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 cross-platform problem. But the first option also has a right to exist - parental control.
If the offline application can only filter the user's personal feed, then the browser extension will “walk” with the user. I have children who have not yet used, but will soon be using a computer.
Imagine that the application can develop to such a simple service, where there will be an online database of dictionaries / masks by category (for example: VK 18+, classmates advertising)
And browser extensions that support multiple social. networks.
Install the extension and select dictionaries. The child searches for videos, views his news, other people's pages, communities, and the content is run through the filter and unwanted elements are hidden / deleted.
A sort of AdBlock analogue.
There is another problem - duplicates. I'm not talking about reposts, but about cases when the same content is posted on behalf of a particular community / person. The situation is quite common. Perhaps this is an application that saves a kind of fingerprint of a post to the database "I have already seen this, you can no longer display it." Often posts are simply copied from each other, and very rarely content is copied. By the way, with such an application, the problem with repeated advertising posts in the feed will be solved.
The opinions of the Khabrovsk residents on this matter are interesting.
And finally, a survey on the topic.
PS Perhaps such applications / services already exist, but I did not find such, if anyone knows, share it.
Good to all.
Only registered users can participate in the survey. Please come in.
Do you need a third-party tool for filtering inappropriate content in social media? networks?
- 11.7% None. I try to fight on my own. 75
- 41.2% None. This does not bother me. 263
- 3.6% Yes. An offline application that has access to my feed. 23
- 22.9% Yes. Online applications and scripts for browsers. 146
- 20.4% Yes. Both remedies are good. 130