// ======================================= // СПИСОК ЗАБЛОКИРОВАННЫХ // ======================================= var block = [ "Чужая2_3", "ник1", "ник2", ]; // ======================================= var posts = document.getElementsByClassName("alt2"); for (var i = 0; i < posts.length; i++) { if(posts[i].querySelector("div > a > b") != null) { if(block.indexOf(posts[i].querySelector("div > a > b").innerText) != -1) { var el = posts[i].querySelector("div > a > b").parentNode.parentNode.parentNode.parentNode; el.style.visibility = "collapse"; } } } // ======================================= // URL // ======================================= // ======================================= // YOUTUBE справочно, неисполняемый код // ======================================= function youtube_parser(url) { var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]{11,11}).*/; var match = url.match(regExp); if (match) if (match.length >= 2) return match[2]; } function addTextAtCursorPosition(textArea, cursorPosition, text) { var front = (textArea.value).substring(0, cursorPosition); var back = (textArea.value).substring(cursorPosition, textArea.value.length); textArea.value = front + text + back; } function updateCursorPosition(cursorPosition, text, textArea) { cursorPosition = cursorPosition + text.length; textArea.selectionStart = cursorPosition; textArea.selectionEnd = cursorPosition; textArea.focus(); } function addTextAtCaret(textAreaId, text) { var videoID = youtube_parser(text); if(videoID !== undefined) { videoID = '[youtube]' + videoID + '[/youtube]'; var textArea = document.getElementById(textAreaId); var cursorPosition = textArea.selectionStart; addTextAtCursorPosition(textArea, cursorPosition, videoID); updateCursorPosition(cursorPosition, videoID, textArea); } } function addYouTube() { result = prompt("Введите полный URL YouTube:"); if(result) addTextAtCaret('vB_Editor_QR_textarea', result); } // ======================================= // ЦИТИРОВАНИЕ справочно, неисполняемый код // ======================================= function quote_parser(str) { var result = new Array(); var regexp_num = new RegExp(/\d+/); var num = regexp_num.exec(str)[0]; result.push(num); var regexp_name = new RegExp(/'(.*?)'/); var name = regexp_name.exec(str)[0].toString(); name = name.replace(/[']/g,''); result.push(decodeURI(name)); return result; } function quote_selection_new() { var str; var result; var txt = ""; var quote; if (window.getSelection) { txt = window.getSelection().toString(); } else if (document.getSelection) { txt = document.getSelection(); } else if (document.selection) { txt = document.selection.createRange().text; } if(txt != "") { var s = window.getSelection().focusNode.parentElement; for(i = 0; i < document.getElementsByTagName('*').length; i++) { if(s.tagName == "BODY") break; else if(s.tagName == "TR") break; else if(s.parentElement.querySelector('td[style="padding: 5px 5px 20px; color: #0000cc;"]')) { str = s.parentElement.querySelector('a[title="Цитировать выделенный фрагмент"]'); break; } s = s.parentElement; } result = quote_parser(str); quote = '[quote=' + quote_parser(str)[1] + ';' + quote_parser(str)[0] + "]" + txt + "[/quote]"; var textArea = document.getElementById("vB_Editor_QR_textarea"); var cursorPosition = textArea.selectionStart; addTextAtCursorPosition(textArea, cursorPosition, quote); updateCursorPosition(cursorPosition, quote, textArea); } else { bbcode('[quote]','[/quote]'); } } // ======================================= // SCRIPT eval исполняемый код // ======================================= var textscript = "function youtube_parser(url) {\n\t\tvar regExp = /^.*(youtu.be\\/|v\\/|u\\/\\w\\/|embed\\/|watch\\?v=|\\\&v=)([^#\\\&\\?]{11,11}).*/;\n\t\tvar match = url.match(regExp);\n\t\tif (match) if (match.length >= 2) return match[2];\n }\n\n\tfunction addTextAtCursorPosition(textArea, cursorPosition, text) {\n\t var front = (textArea.value).substring(0, cursorPosition);\n\t var back = (textArea.value).substring(cursorPosition, textArea.value.length);\n\t textArea.value = front + text + back;\n\t}\n\tfunction updateCursorPosition(cursorPosition, text, textArea) {\n\t cursorPosition = cursorPosition + text.length;\n\t textArea.selectionStart = cursorPosition;\n\t textArea.selectionEnd = cursorPosition;\n\t textArea.focus(); \n\t}\n\tfunction addTextAtCaret(textAreaId, text) {\n\t\tvar videoID = youtube_parser(text);\n\t\tif(videoID !== undefined) {\n\t\t\tvideoID = \'[youtube]\' + videoID + \'[/youtube]\';\n\t\t var textArea = document.getElementById(textAreaId);\n\t\t var cursorPosition = textArea.selectionStart;\n\t\t addTextAtCursorPosition(textArea, cursorPosition, videoID);\n\t\t updateCursorPosition(cursorPosition, videoID, textArea);\n\t\t}\n\t}\n\t\n\tfunction addYouTube() {\n\t\tresult = prompt(\"Введите полный URL YouTube:\");\n\t\tif(result) addTextAtCaret(\'vB_Editor_QR_textarea\', result);\n\t}\n\t\nfunction quote_parser(str) {\n\t\n\tvar result = new Array();\n\n\tvar regexp_num = new RegExp(/\\d+/);\n\tvar num = regexp_num.exec(str)[0];\n\tresult.push(num);\n\n\tvar regexp_name = new RegExp(/\'(.*?)\'/);\n\tvar name = regexp_name.exec(str)[0].toString();\n\tname = name.replace(/[\']/g,\'\');\n\tresult.push(decodeURI(name));\n\n\treturn result;\n}\n\nfunction quote_selection_new() {\n\t\n\tvar str;\n\tvar result;\n\tvar txt = \"\";\n\tvar quote;\n\n\tif (window.getSelection) {\n\t\ttxt = window.getSelection().toString();\n\t } else if (document.getSelection) {\n\t txt = document.getSelection();\n\t } else if (document.selection) {\n\t txt = document.selection.createRange().text;\n\t }\n\n\tif(txt != \"\") {\n\n\t\tvar s = window.getSelection().focusNode.parentElement;\n\t\tfor(i = 0; i < document.getElementsByTagName(\'*\').length; i++) {\n\t\t\t\n\t\t\tif(s.tagName == \"BODY\") break;\n\t\t\telse if(s.tagName == \"TR\") break;\n\t\t\t\telse if(s.parentElement.querySelector(\'td[style=\"padding: 5px 5px 20px; color: #0000cc;\"]\')) {\n\t\t\t\t\t\tstr = s.parentElement.querySelector(\'a[title=\"Цитировать выделенный фрагмент\"]\');\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\n\t\t\t\ts = s.parentElement;\n\t\t}\n\n\t\t\tresult = quote_parser(str);\n\t\t\tquote = \'[quote=\' + quote_parser(str)[1] + \';\' + quote_parser(str)[0] + \"]\" + txt + \"[/quote]\";\n\t\t\tvar textArea = document.getElementById(\"vB_Editor_QR_textarea\");\n\t\t\tvar cursorPosition = textArea.selectionStart;\n\t\t\taddTextAtCursorPosition(textArea, cursorPosition, quote);\n\t\t\tupdateCursorPosition(cursorPosition, quote, textArea);\n\t} else {\n\t\tbbcode(\'[quote]\',\'[/quote]\');\n\t}\n}"; var script = document.createElement("script"); script.type="text/javascript"; script.innerHTML = textscript; document.getElementsByTagName('head')[0].appendChild(script); // ======================================= // Добавление ссылок к форме // ======================================= var fieldset; if(document.getElementsByClassName("fieldset").length > 1) { fieldset = document.getElementsByClassName("fieldset").item(2); } else { fieldset = document.getElementsByClassName("fieldset").item(0); } // URL var link = document.createElement('a'); link.href = 'javascript:bbcode(\'[url]\',\'[/url]\')'; link.setAttribute('style', 'margin-left: 10px; vertical-align: 4px;'); link.textContent = "URL"; fieldset.querySelector("div").appendChild(link); // YouTube var youtube = document.createElement('a'); // youtube.setAttribute('href', 'javascript:bbcode(\'[youtube]\',\'[/youtube]\')'); youtube.href = 'javascript:addYouTube()'; youtube.setAttribute('style', 'margin-left: 10px; vertical-align: 4px;'); youtube.textContent = "YouTube"; fieldset.querySelector("div").appendChild(youtube); // QUOTE var quote = document.createElement('a'); // quote.href = 'javascript:bbcode(\'[quote]\',\'[/quote]\')'; quote.href = 'javascript:quote_selection_new()'; quote.setAttribute('style', 'margin-left: 10px; vertical-align: 4px;'); quote.textContent = "Цитата"; fieldset.querySelector("div").appendChild(quote);