// ======================================= // СПИСОК ЗАБЛОКИРОВАННЫХ // ======================================= var block = [ "Чужая2_3", "User_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 // ======================================= var fieldset = document.getElementsByClassName("fieldset"); var link = document.createElement('a'); link.href = 'javascript:bbcode(\'[url]\',\'[/url]\')'; link.setAttribute('style', 'margin-left: 10px; vertical-align: 4px;'); link.textContent = "URL"; fieldset.item(0).querySelector("div").appendChild(link); // ======================================= // 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); } // ======================================= // YOUTUBE исполняемый код // ======================================= 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}"; var script = document.createElement("script"); script.type="text/javascript"; script.innerHTML = textscript; document.getElementsByTagName('head')[0].appendChild(script); 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.item(0).querySelector("div").appendChild(youtube);