Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //The script will hide posts with TEXT_FLAG in their tags (tags != source, fyi)
- var TEXT_FLAG = "father";
- //Adds contains to String prototype,
- //returns true if string contains substring
- String.prototype.contains = function(it) { return this.indexOf(it) != -1; };
- //list = all <li>, posts are contained there
- //list_array = just id numbers for posts
- var list = document.getElementsByTagName('li');
- var list_array = new Array();
- //populate array with every post id
- for (var i = 0, length = list.length; i < length; i++) {
- if( /post_[\d]+/.test(list[i].id) ){
- var id_number = list[i].id.split(/_/)[1];
- list_array.push(id_number);
- }
- }
- //cycle posts ids in array, search tags, if tags match TEXT_FLAG, hide element
- for(var i = 0, length = list_array.length; i < length; i++){
- var tag = document.getElementById("post_tags_"+list_array[i]);
- if(tag){
- var tags = tag.getElementsByTagName("a");
- for(var j = 0, length = tags.length; j < length; j++){
- tag_text = tags[j].text;
- if( tag_text.contains(TEXT_FLAG) ){
- //console.log(tags[j].text);
- var content = document.getElementById("post_"+list_array[i])
- content.style.visibility = "hidden";
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment