Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name DobroHider
- // @namespace dobrocode
- // @description Dobrochan threads autohider
- // @include http://dobrochan.ru/*/*.xhtml
- // @include https://dobrochan.ru/*/*.xhtml
- // @include http://dobrochan.ru/settings
- // @include https://dobrochan.ru/settings
- // @exclude http://dobrochan.ru/*/res/*.xhtml*
- // @exclude https://dobrochan.ru/*/res/*.xhtml*
- // @include http://dobrochan.com/*/*.xhtml
- // @include https://dobrochan.com/*/*.xhtml
- // @include http://dobrochan.com/settings
- // @include https://dobrochan.com/settings
- // @exclude http://dobrochan.com/*/res/*.xhtml*
- // @exclude https://dobrochan.com/*/res/*.xhtml*
- // ==/UserScript==
- var script = document.createElement("script");
- script.textContent = "(" + main.toString() + ")();";
- document.body.appendChild(script);
- function main() {
- function getCookie(name) {
- var one, arr = document.cookie.split('; '), i = arr.length;
- while(i--) { one = arr[i].split('='); if(one[0] == escape(name)) return unescape(one[1]); }
- return false;
- }
- function hide_thread_silent(board, thread)
- {
- $.get('/api/thread/'+board+'/'+thread+'/hide.json', {}, function(response){$('#thread_'+thread).hide("slow")});
- }
- // settings
- if(location.href=="https://dobrochan.ru/settings" || location.href=="http://dobrochan.ru/settings" || location.href=="https://dobrochan.com/settings" || location.href=="http://dobrochan.com/settings")
- {
- var global_table = document.getElementById('ajax-form').parentNode.parentNode
- var auto_column = document.createElement("td")
- var autohide_value = getCookie('autohide')
- auto_column.innerHTML = "<td><span class=\"logo\">Автоскрытие тредов:</span>" +
- "<br><textarea id=\"autohide_settings\" cols=\"60\" rows=\"10\" onChange=\"" +
- "document.cookie = escape('autohide') + '=' + escape(document.getElementById('autohide_settings').value) + ';expires=Mon, 01-Jan-2032 00:00:00 GMT'" +
- "\"></textarea></td>"
- auto_column.setAttribute("style","padding-left: 20px; vertical-align:top")
- global_table.appendChild(auto_column)
- if(autohide_value)
- document.getElementById('autohide_settings').value = autohide_value
- }
- else
- {
- // board
- var auto_hide_arr = getCookie('autohide').split('\n')
- var op_posts = document.getElementsByClassName('oppost post')
- var desk = new RegExp("dobrochan.(?:ru|com)/([a-z]{1,4})").exec(location.href)[1];
- var index = 0;
- for( index = 0; index < op_posts.length; index++)
- {
- var titles = op_posts[index].getElementsByClassName("replytitle");
- if(titles.length > 0)
- {
- var op_title = titles[0].innerHTML
- var rx_index = 0;
- for( rx_index = 0; rx_index<auto_hide_arr.length; rx_index++)
- {
- if(auto_hide_arr[rx_index].length==0)
- continue
- var rx = new RegExp(auto_hide_arr[rx_index],"i")
- if(rx.test(op_title))
- {
- var thread_id = op_posts[index].id;
- thread_id = thread_id.replace("post_","");
- hide_thread_silent(desk, thread_id)
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment