Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name pouetBBCodeToolbar
- // @description Add a bbcode toolbar for pouet
- // @include http://pouet.net/*
- // @exclude http://pouet.net/
- // @exclude http://pouet.net/index.php*
- // @include http://www.pouet.net/*
- // @exclude http://www.pouet.net/
- // @exclude http://www.pouet.net/index.php*
- // ==/UserScript==
- /*
- * 2013.09.19 Tigrou^ind ( tigrou.ind@gmail.com ).
- */
- !(function ()
- {
- insertTags = function (link, start, end)
- {
- var t = link.parentNode.nextSibling;
- var from = t.selectionStart;
- var to = t.selectionEnd;
- t.value = t.value.slice(0, t.selectionStart) + start
- + t.value.slice(t.selectionStart, t.selectionEnd)
- + end + t.value.slice(t.selectionEnd);
- t.selectionStart = from + start.length;
- t.selectionEnd = to + start.length;
- }
- var textareas = document.querySelectorAll('textarea');
- for( var i=0; i < textareas.length; i++)
- {
- var spanStyle = 'font-weight:bold;display:inline-block;padding:2px 10px;margin:2px;border:1px solid #9FCFFF';
- var t = textareas[i];
- var d = document.createElement('div');
- d.style.padding = '5px';
- d.style.color = '#9FCFFF';
- d.innerHTML = '<span style="'+spanStyle+'" onclick="insertTags(this, \'[url]\', \'[/url]\')">url</span> ' +
- '<span style="'+spanStyle+'" onclick="insertTags(this, \'[url=\'+prompt(\'URL\')+\']\', \'[/url]\')">url with text</span> ' +
- '<span style="'+spanStyle+'" onclick="insertTags(this, \'[img]\', \'[/img]\')">img</span> ' +
- '<span style="'+spanStyle+';margin-left:10px" onclick="insertTags(this, \'[code]\', \'[/code]\')">code</span> ' +
- '<span style="'+spanStyle+'" onclick="insertTags(this, \'[quote]\', \'[/quote]\')">quote</span> ' +
- '<span style="'+spanStyle+';margin-left:10px" onclick="insertTags(this, \'[b]\', \'[/b]\')">bold</span> ' +
- '<span style="'+spanStyle+'" onclick="insertTags(this, \'[i]\', \'[/i]\')">italic</span>';
- t.parentNode.insertBefore(d, t);
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement