Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name fv - rich text editor (PMs)
- // @author CuteHornyUnicorn
- // @namespace CuteHornyUnicorn
- // @version 0.1b4
- // @description Wysiwyg editor for Furvilla Forums
- // @include http://www.furvilla.com/message/*
- // @require http://code.jquery.com/jquery-latest.js
- // @require https://gist.github.com/rooftopchicken/4fba6ed0127dc94bb86179aa4e127dc4/raw/675e4c8c3dc9dcb7fddb0423b45253da7e7110b1/testwysibbnopaste.js
- // @resource customCSS http://cdn.wysibb.com/css/default/wbbtheme.css
- // @grant GM_addStyle
- // @grant GM_getResourceText
- // ==/UserScript==
- /*jshint multistr: true */
- var insertAfter = function(x, y){
- y.parentNode.insertBefore(x, y.nextSibling);
- };
- var getOldSubmit = document.querySelector('input[value="Send"]');
- if (getOldSubmit) var oldSubmit = getOldSubmit;
- var getOldSubmit = document.querySelector('input[value="Send Message"]');
- if (getOldSubmit) var oldSubmit = getOldSubmit;
- oldSubmit.style = "display:none;";
- var newSubmit = document.createElement('a');
- newSubmit.setAttribute('class', 'btn btn-small pull-right');
- newSubmit.setAttribute('id', 'syncSubmit');
- newSubmit.textContent = 'Send';
- insertAfter(newSubmit, oldSubmit);
- var newCSS = GM_getResourceText ("customCSS");
- GM_addStyle (newCSS);
- GM_addStyle("\
- .wysibb {\
- font-size: medium !important;\
- }\
- .wysibb-body {\
- overflow-y: auto !important;\
- }\
- ");
- var wbbOpt = {
- traceTextarea: true,
- onlyBBmode: false,
- buttons: "bold,italic,underline,strike,spoiler,|,img,video,link,|,fontcolor,fontsize,|,justifyleft,justifycenter,justifyright,|,quote,bullist,numlist,table,float,code,removeFormat",
- allButtons: {
- quote: {
- transform: {
- '<div class="quote"><div class="quote-body">{SELTEXT}</div></div>':'[quote]{SELTEXT}[/quote]',
- '<div class="quote"><div class="quote-user">{AUTHOR} said:</div><div class="quote-body">{SELTEXT}</div></div>':'[quote={AUTHOR}]{SELTEXT}[/quote]'
- }
- },
- img: {
- modal: { //Description of modal window
- title: "Insert image",
- width: "600px",
- tabs: [
- {
- input: [ //List of form fields
- {param: "SRC",title:"Enter image URL",validation: '^http(s)?://.*?\.(jpg|png|gif|jpeg)$'},
- {param: "WIDTH",title:"Enter width",validation: '^[0-9]*$'},
- {param: "HEIGHT",title:"Enter height",validation: '^[0-9]*$'}
- ]
- }
- ],
- onLoad: function() {
- //Callback function that will be called after the display of a modal window
- },
- onSubmit: function() {
- //Callback function that will be called by pressing the "Save"
- //If function return false, it means sending data WysiBB not be made
- var width = this.$modal.find('input[name="WIDTH"]').val();
- var height = this.$modal.find('input[name="HEIGHT"]').val();
- if ( (width === '' && height !== '') || (width !== '' && height === '')) {
- alert("Either leave width & height both blank or both filled, not one or the other!");
- return false;
- }
- }
- },
- transform: {
- '<img src="{SRC}" />':"[img]{SRC}[/img]",
- '<img width="{WIDTH}" height="{HEIGHT}" src="{SRC}">':'[img={WIDTH}x{HEIGHT}]{SRC}[/img]'
- }
- },
- video: {
- transform:{'<iframe src="http://www.youtube.com/embed/{SRC}" width="640" height="480" frameborder="0"></iframe>':"[youtube]{SRC}[/youtube]"}
- },
- fontsize: {
- options:"fs_verysmall,fs_small,fs_normal,fs_big,fs_bigger,fs_verybig,fs_biggest"
- },
- fs_verysmall: {
- transform:{'<font size="1">{SELTEXT}</font>':"[size=1]{SELTEXT}[/size]"}
- },
- fs_small: {
- transform:{'<font size="2">{SELTEXT}</font>':"[size=2]{SELTEXT}[/size]"}
- },
- fs_normal: {
- title:'Medium',
- buttonText:"Medium",
- transform:{'<font size="3">{SELTEXT}</font>':"[size=3]{SELTEXT}[/size]"}
- },
- fs_big: {
- transform:{'<font size="4">{SELTEXT}</font>':"[size=4]{SELTEXT}[/size]"}
- },
- fs_bigger: {
- title:'Bigger',
- buttonText:"Bigger",
- transform:{'<font size="5">{SELTEXT}</font>':"[size=5]{SELTEXT}[/size]"}
- },
- fs_verybig: {
- transform:{'<font size="6">{SELTEXT}</font>':"[size=6]{SELTEXT}[/size]"}
- },
- fs_biggest: {
- title:'Biggest',
- buttonText:"Biggest",
- transform:{'<font size="7">{SELTEXT}</font>':"[size=7]{SELTEXT}[/size]"}
- },
- bullist: {
- transform: {
- '<ul>{SELTEXT}</ul>':"[list]{SELTEXT}[/list]",
- '<li>{SELTEXT}</li>':"[*]{SELTEXT}\n"
- }
- },
- float: {
- type: 'select',
- title: 'Float',
- options: "f_left,f_right,f_clear"
- },
- f_left: {
- title: 'Left',
- buttonText: "Left",
- transform: {
- '<div class="float-left">{SELTEXT}</div>':"[floatleft]{SELTEXT}[/floatleft]"
- }
- },
- f_right: {
- title: 'Right',
- buttonText: "Right",
- transform: {
- '<div class="float-right">{SELTEXT}</div>':"[floatright]{SELTEXT}[/floatright]"
- }
- },
- f_clear: {
- title: 'Clear',
- buttonText: "Clear",
- transform: {
- '<div class="clearfix"></div>':"[floatclear]"
- }
- },
- spoiler: {
- title: 'Spoiler',
- buttonText: "Spoiler",
- transform: {
- '<span class="spoiler">{SELTEXT}</span>': '[spoiler]{SELTEXT}[/spoiler]'
- }
- },
- }};
- $(function() {
- $(".textarea").wysibb(wbbOpt);
- });
- function syncPreview() {
- $(".textarea").sync();
- oldPreview.click();
- }
- function syncSubmit() {
- $(".textarea").sync();
- oldSubmit.click();
- }
- $("#syncPreview").click(syncPreview);
- $("#syncSubmit").click(syncSubmit);
- $( document ).ready(function() {
- var testt = document.querySelector('.wysibb-text-editor');
- testt.setAttribute('class', 'thread-user-post-middle readable wysibb-text-editor wysibb-body');
- });
- $(document).on('paste','[contenteditable]',function(e) {
- e.preventDefault();
- var text = (e.originalEvent || e).clipboardData.getData('text/plain');
- window.document.execCommand('insertText', false, text);
- });
Advertisement
Add Comment
Please, Sign In to add comment