NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name SDMB S Button Adder // @version 6 // @description Adds strikeout, spoiler, subscript, and superscript buttons to the SDMB post box. // @author BigT@SDMB // @updateURL https://openuserjs.org/meta/BigTSDMB/SDMB_Add_Strikeout_button.meta.js // @license MIT // @match *://boards.straightdope.com/sdmb/showthread.php* // @match *://boards.straightdope.com/sdmb/newreply.php* // @match *://boards.straightdope.com/sdmb/private.php* // @run-at document-start // @grant none // ==/UserScript== function addStyle(css, id) { var style = document.createElement('style'); style.innerText = css; if (id) style.id = id; document.documentElement.appendChild(style); } var delButton = document.createElement('td'), delImgURL = 'data:image/gif;base64,R0lGODlhFQAUAPD/AICAgAAAACH5BAUIAAIALAUABQALAAsAAAIblINoiyCgWJDrBVdF2jtbfExh1QCQKCXeylYFADs', spoilButton = document.createElement('td'), spoilImgURL = 'data:image/gif;base64,R0lGODlhFAAUAMIEAAMFAFxIAruVAOKzAP///////////////yH5BAEIAAQALAMAAwAOAA4AAAM6SKrQ+yyIMQKApEnB7WsNx4ELCASURZrhwGZsoK4ixVGDECgb1diCS0ak2gRLI9AIcjJ5MCwhZrpIAAA7', supButton = document.createElement('td'), supImgURL = 'data:image/gif;base64,R0lGODlhFQAUAKUAAAAAAAYGBgwMDA4ODhwcHCQkJCwsLC4uLjY2Njg4ODo6Ojw8PEJCQkZGRlJSUlZWVlpaWl5eXmJiYiRy1mpqaix22nBwcDB82nR0dHh4eESA20KG3UaK34WFhYeHh16M3lKQ4liY6JWVlWai7Xyg52qm7HCo7a2trYuy7ou08LGxsb29vavB7cXFxbvM8MvLy8/d9d3d3efn5+vr6+fw/+nz/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEKAD8ALAAAAAAVABQAAAZgwJ9wSCwaj8ikcqmslUYpZtFEQ4WkRhAnibFQJDJHY/EjbWDJFsPQ+XkiMdbn51K+CgSRQqi5VCZLGQIAM1hEAAARhkIJHYgnWDMQbQ6IK1IIBw8rAwGIKouhoqOkpaZBADs', subButton = document.createElement('td'), subImgURL = 'data:image/gif;base64,R0lGODlhFQAUAKUAAAAAAAYGBgkJCQwMDBUVFRkZGR0dHSQkJCwsLDY2Njk5OUJCQkNDQ0VFRUtLS05OTlpaWmBgYGNjY2VlZWlpaShy0TB41XBwcDN71XZ2dkV903p6ekaF139/f0uN3YWFhWCL2ImJiYuLi1iS4FqW4ZiYmGmi6Hye3mqj5W2j4oOn4Iiv6LGxsbm5uae85by8vLPC6MLCwsbGxsrKysbR6OHh4drj8Obm5t7n9OTn7+zs7Pj4+Pn5+f///wAAAAAAACH5BAEKAD8ALAAAAAAVABQAAAZjwJ9wSCwaj8ikcslsOp/LTeZCuUEejabMkQj1RJOac4Y4lBjQX6cg0KV1goAkvQgBAKwfDmVaJW8RHzsQdy8pNiokSQsKEjEGBAMBLTwjHmk/Jxw0aS4gOTBpGhgWFZinqEpBADs', innerHTML = ['<div class="imagebutton s-button" id="', '" style="background: rgb(225, 225, 226); color: rgb(0, 0, 0); padding: 1px; border: none;"><img src="', '" width="21" height="20" alt="'], x2x2ImgURL = 'data:image/gif;base64,R0lGODlhLAAUAKU8AAABAAQHAggLBxASDxocGSMkIiwtKzc4Njs9OkFCQEZIRVBRT1VWVFlbWF5fXWJkYRJz0xt03GhpZ2xuayd81il73Tt82HR2c0h81Hp8eUaF2z6L4ISGg2CL2FqN31GQ4ImLiFaX4VqY6ZWXlGKj52Si7Xmf4Guk4n2f6G+l6n+n4oqx7a6wrbi6t6e/6ry+u6/D6cfJxbnN88jQ5sve+Nze29nl9OTm4+bn8ers6eby//n8+AAAAAAAAAAAAAAAACH5BAEKAD8ALAAAAAAsABQAAAa0wJ9wSCwaj8ikcslsOp/Q6FOXKq2k2GFKtxJlv7/PJpm5TCS3xkLxNEsetzXih9LQkjHFAbQDPWpPMQkGHD8cDjUuHj8ySjEGBSMJUjEFBCMHQhYVERFLGQQBOVgXAqJROQEBD1mqDlEJIKosPzYkKVdMBxyzTjcOHDsNqi0nNiohSzkNhQuqL00JBw8vBAOmLTsfH0sHBgwvA6oBtFkmGjNgUi4dODDqURgUFhDw9vf4+fpBADs'; delButton.innerHTML = innerHTML[0] + 'vB_Editor_cmd_wrap0_del' + innerHTML[1] + delImgURL + innerHTML[2] + 'Strikeout"></div>'; spoilButton.innerHTML = innerHTML[0] + 'vB_Editor_cmd_wrap0_spoiler' + innerHTML[1] + spoilImgURL + innerHTML[2] + 'Wrap [SPOILER] tags around selected text"></div>'; supButton.innerHTML = innerHTML[0] + 'vB_Editor_cmd_wrap0_spoiler' + innerHTML[1] + supImgURL + innerHTML[2] + 'Superscript"></div>'; subButton.innerHTML = innerHTML[0] + 'vB_Editor_cmd_wrap0_spoiler' + innerHTML[1] + subImgURL + innerHTML[2] + 'Subscript"></div>'; addStyle('.s-button:hover { background: rgb(193, 210, 238) !important; border: 1px solid rgb(49, 106, 197) !important; padding: 0px !important; }'); addStyle('#vB_Editor_001_controls > table:nth-child(2) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(3)::after { content: url(' + delImgURL + '); display: table-cell; padding: 1px; } #vB_Editor_001_cmd_underline { display: table-cell } #vB_Editor_001_controls > table:nth-child(2) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(18)::after { content: url(' + spoilImgURL + '); display: table-cell; padding: 1px; } #vB_Editor_001_cmd_wrap0_quote { display: table-cell } #vB_Editor_001_controls > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(4)::after { content: url(' + x2x2ImgURL + '); display: table-cell; padding: 0 1px 1px 0; } #vB_Editor_001_popup_fontsize { display: table-cell } /*#vB_Editor_001_controls > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(5)::before { content: url(' + supImgURL + '); display: table-cell; padding: 1px; } img[src=images/editor/separator.gif] { display: table-cell }*/', 's-buttons'); function addButton(prevButtonImg, button) { if (prevButtonImg) { var prevButton = prevButtonImg.parentNode.parentNode; prevButton.parentNode.insertBefore(button, prevButton.nextSibling); } } addEventListener ('DOMContentLoaded', function () { addButton (document.querySelector('[src*="images/editor/underline.gif"]'), delButton); addButton (document.querySelector('[src*="images/editor/quote.gif"]'), spoilButton); addButton (document.querySelector('div[id*="_popup_fontsize"] > table'), supButton); addButton (document.querySelector('div[id*="_popup_fontsize"] > table'), subButton); document.getElementById('s-buttons').remove(); var vB_Editor = window.vB_Editor || window.wrappedJSObject.vB_Editor; var editorID = Object.keys(vB_Editor)[0]; delButton.addEventListener ('click', function(event) { vB_Editor[editorID].format(event, 'wrap0_del'); }); spoilButton.addEventListener ('click', function(event) { vB_Editor[editorID].format(event, 'wrap0_spoiler'); }); supButton.addEventListener ('click', function(event) { vB_Editor[editorID].format(event, 'wrap0_sup'); }); subButton.addEventListener ('click', function(event) { vB_Editor[editorID].format(event, 'wrap0_sub'); }); });/**/