// ==UserScript== // @name Additional buttons for Lists, Posts and PMs // @description adds buttons // @version 1.91 // @include https://rateyourmusic.com/lists/new_item* // @include https://rateyourmusic.com/board_new_message?* // @include https://rateyourmusic.com/messages/compose?* // @include https://rateyourmusic.com/collection/* // @include http://rateyourmusic.com/collection/* // @include https://rateyourmusic.com/~* // @include https://rateyourmusic.com/list/* // @exclude https://rateyourmusic.com/collection/*/stag/* // @exclude http://rateyourmusic.com/collection/*/stag/* // @grant metadata // @require http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js // @namespace https://greasyfork.org/users/2625 // @downloadURL https://update.greasyfork.icu/scripts/2252/Additional%20buttons%20for%20Lists%2C%20Posts%20and%20PMs.user.js // @updateURL https://update.greasyfork.icu/scripts/2252/Additional%20buttons%20for%20Lists%2C%20Posts%20and%20PMs.meta.js // ==/UserScript== var textArea; if (document.URL.indexOf("/list/") > 0) { flag = document.getElementsByClassName('fav0')[0]; if (flag != undefined) { listId = flag.getAttribute('id').split('_')[1] } textArea = 'comments_list_comments_s_c_'+listId; $('.commentbutton:eq(0)').parent().attr('style','height:75px;') $('#list_comments_dummybutton').attr('style','height:75px;width:100%;') } else if (document.URL.indexOf("~") > 0) { userId = $('#shoutbox_assoc_id').val(); textArea = 'comments_shoutbox_u_c_' + userId; $('.commentbutton:eq(0)').parent().attr('style','height:75px;') $('#list_comments_dummybutton').attr('style','height:75px;width:100%;') } else { var boxTypes = ['msg_body', 'item_description','body']; i = -1; while (textBox == undefined && i < boxTypes.length) { i++; var textBox = document.getElementById(boxTypes[i]); textArea = boxTypes[i]; } } if (textArea != undefined){addButtons(textArea)} function spoil(){ editTextareaTwo('asdf', 'asfd') } function editTextareaTwo(addBefore, addAfter) { var c = document.getElementById(textArea); if (document.selection) { var g = document.selection.createRange().text; c.focus(); var e = document.selection.createRange(); e.text = addBefore + g + addAfter } else { if (c.selectionStart | c.selectionStart == 0) { if (c.selectionEnd > c.value.length) { c.selectionEnd = c.value.length } var h = c.selectionStart; var b = c.selectionEnd + addBefore.length; c.value = c.value.slice(0, h) + addBefore + c.value.slice(h); c.value = c.value.slice(0, b) + addAfter + c.value.slice(b); c.selectionStart = h + addBefore.length; c.selectionEnd = b; c.focus() } } } function addButtons(prev) { msg_body = document.getElementById(prev); if ($('#'+prev)) { var btnContents = [['bold','strong','B'],['italic','emphasis','I'],['link','a_href','link']]; var btnTemplate = 'S')) document.getElementById('strikethrough').addEventListener('click', function(){editTextareaTwo('[s]','[/s]')}, false) if (document.URL.indexOf("~") < 0 && document.URL.indexOf("/list/") < 0) { $('#'+prev).before('