msjanny

FV PMs editor

Jun 17th, 2019
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        fv - rich text editor (PMs)
  3. // @author      CuteHornyUnicorn
  4. // @namespace   CuteHornyUnicorn
  5. // @version     0.1b4
  6. // @description Wysiwyg editor for Furvilla Forums
  7. // @include     http://www.furvilla.com/message/*
  8. // @require     http://code.jquery.com/jquery-latest.js
  9. // @require     https://gist.github.com/rooftopchicken/4fba6ed0127dc94bb86179aa4e127dc4/raw/675e4c8c3dc9dcb7fddb0423b45253da7e7110b1/testwysibbnopaste.js
  10. // @resource    customCSS http://cdn.wysibb.com/css/default/wbbtheme.css
  11. // @grant       GM_addStyle
  12. // @grant       GM_getResourceText
  13. // ==/UserScript==
  14. /*jshint multistr: true */
  15.  
  16.     var insertAfter = function(x, y){
  17.         y.parentNode.insertBefore(x, y.nextSibling);
  18.     };
  19.  
  20.  
  21.                 var getOldSubmit = document.querySelector('input[value="Send"]');
  22. if (getOldSubmit) var oldSubmit = getOldSubmit;
  23.  
  24.                 var getOldSubmit = document.querySelector('input[value="Send Message"]');
  25. if (getOldSubmit) var oldSubmit = getOldSubmit;
  26.  
  27. oldSubmit.style = "display:none;";
  28. var newSubmit = document.createElement('a');
  29. newSubmit.setAttribute('class', 'btn btn-small pull-right');
  30. newSubmit.setAttribute('id', 'syncSubmit');
  31. newSubmit.textContent = 'Send';
  32. insertAfter(newSubmit, oldSubmit);
  33.  
  34.  
  35. var newCSS = GM_getResourceText ("customCSS");
  36. GM_addStyle (newCSS);
  37.     GM_addStyle("\
  38.     .wysibb {\
  39.         font-size: medium !important;\
  40.     }\
  41.    .wysibb-body {\
  42.        overflow-y: auto !important;\
  43.    }\
  44.     ");
  45.  
  46.  
  47. var wbbOpt = {
  48. traceTextarea: true,
  49. onlyBBmode: false,
  50. buttons: "bold,italic,underline,strike,spoiler,|,img,video,link,|,fontcolor,fontsize,|,justifyleft,justifycenter,justifyright,|,quote,bullist,numlist,table,float,code,removeFormat",
  51.   allButtons: {
  52.     quote: {
  53.       transform: {
  54.         '<div class="quote"><div class="quote-body">{SELTEXT}</div></div>':'[quote]{SELTEXT}[/quote]',
  55.         '<div class="quote"><div class="quote-user">{AUTHOR} said:</div><div class="quote-body">{SELTEXT}</div></div>':'[quote={AUTHOR}]{SELTEXT}[/quote]'
  56.       }
  57.     },
  58.     img: {
  59.       modal: { //Description of modal window
  60.         title: "Insert image",
  61.         width: "600px",
  62.         tabs: [
  63.           {
  64.             input: [ //List of form fields
  65.               {param: "SRC",title:"Enter image URL",validation: '^http(s)?://.*?\.(jpg|png|gif|jpeg)$'},
  66.               {param: "WIDTH",title:"Enter width",validation: '^[0-9]*$'},
  67.               {param: "HEIGHT",title:"Enter height",validation: '^[0-9]*$'}
  68.             ]
  69.           }
  70.         ],
  71.         onLoad: function() {
  72.           //Callback function that will be called after the display of a modal window
  73.         },
  74.         onSubmit: function() {
  75.           //Callback function that will be called by pressing the "Save"
  76.           //If function return false, it means sending data WysiBB not be made
  77.           var width = this.$modal.find('input[name="WIDTH"]').val();
  78.           var height = this.$modal.find('input[name="HEIGHT"]').val();
  79.  
  80.           if ( (width === '' && height !== '') || (width !== '' && height === '')) {
  81.               alert("Either leave width & height both blank or both filled, not one or the other!");
  82.               return false;
  83.           }
  84.         }
  85.       },
  86.       transform: {
  87.         '<img src="{SRC}" />':"[img]{SRC}[/img]",
  88.         '<img width="{WIDTH}" height="{HEIGHT}" src="{SRC}">':'[img={WIDTH}x{HEIGHT}]{SRC}[/img]'
  89.       }
  90.     },
  91.     video: {
  92.         transform:{'<iframe src="http://www.youtube.com/embed/{SRC}" width="640" height="480" frameborder="0"></iframe>':"[youtube]{SRC}[/youtube]"}
  93.     },
  94.     fontsize: {
  95.         options:"fs_verysmall,fs_small,fs_normal,fs_big,fs_bigger,fs_verybig,fs_biggest"
  96.     },
  97.     fs_verysmall: {
  98.        transform:{'<font size="1">{SELTEXT}</font>':"[size=1]{SELTEXT}[/size]"}
  99.     },
  100.     fs_small: {
  101.        transform:{'<font size="2">{SELTEXT}</font>':"[size=2]{SELTEXT}[/size]"}
  102.     },
  103.     fs_normal: {
  104.        title:'Medium',
  105.        buttonText:"Medium",
  106.        transform:{'<font size="3">{SELTEXT}</font>':"[size=3]{SELTEXT}[/size]"}
  107.     },
  108.     fs_big: {
  109.        transform:{'<font size="4">{SELTEXT}</font>':"[size=4]{SELTEXT}[/size]"}
  110.     },
  111.     fs_bigger: {
  112.        title:'Bigger',
  113.        buttonText:"Bigger",
  114.        transform:{'<font size="5">{SELTEXT}</font>':"[size=5]{SELTEXT}[/size]"}
  115.     },
  116.     fs_verybig: {
  117.        transform:{'<font size="6">{SELTEXT}</font>':"[size=6]{SELTEXT}[/size]"}
  118.     },
  119.     fs_biggest: {
  120.        title:'Biggest',
  121.        buttonText:"Biggest",
  122.        transform:{'<font size="7">{SELTEXT}</font>':"[size=7]{SELTEXT}[/size]"}
  123.     },
  124.     bullist: {
  125.        transform: {
  126.            '<ul>{SELTEXT}</ul>':"[list]{SELTEXT}[/list]",
  127.            '<li>{SELTEXT}</li>':"[*]{SELTEXT}\n"
  128.        }
  129.     },
  130.     float: {
  131.       type: 'select',
  132.       title: 'Float',
  133.       options: "f_left,f_right,f_clear"
  134.     },
  135.     f_left: {
  136.       title: 'Left',
  137.       buttonText: "Left",
  138.       transform:  {
  139.             '<div class="float-left">{SELTEXT}</div>':"[floatleft]{SELTEXT}[/floatleft]"
  140.       }
  141.     },
  142.     f_right: {
  143.       title: 'Right',
  144.       buttonText: "Right",
  145.       transform: {
  146.             '<div class="float-right">{SELTEXT}</div>':"[floatright]{SELTEXT}[/floatright]"
  147.       }
  148.     },
  149.     f_clear: {
  150.       title: 'Clear',
  151.       buttonText: "Clear",
  152.       transform: {
  153.             '<div class="clearfix"></div>':"[floatclear]"
  154.       }
  155.     },
  156.     spoiler: {
  157.       title: 'Spoiler',
  158.       buttonText: "Spoiler",
  159.       transform: {
  160.             '<span class="spoiler">{SELTEXT}</span>': '[spoiler]{SELTEXT}[/spoiler]'
  161.       }
  162.     },
  163.   }};
  164.  
  165.  
  166.  
  167. $(function() {
  168.   $(".textarea").wysibb(wbbOpt);
  169. });
  170.  
  171.  
  172.  
  173. function syncPreview() {
  174.     $(".textarea").sync();
  175.         oldPreview.click();
  176.  
  177.            }
  178. function syncSubmit() {
  179.     $(".textarea").sync();
  180.         oldSubmit.click();
  181.  
  182.            }
  183.     $("#syncPreview").click(syncPreview);
  184.     $("#syncSubmit").click(syncSubmit);
  185.  
  186. $( document ).ready(function() {
  187. var testt = document.querySelector('.wysibb-text-editor');
  188. testt.setAttribute('class', 'thread-user-post-middle readable wysibb-text-editor wysibb-body');
  189. });
  190.  
  191.                 $(document).on('paste','[contenteditable]',function(e) {
  192.                   e.preventDefault();
  193.                   var text = (e.originalEvent || e).clipboardData.getData('text/plain');
  194.                   window.document.execCommand('insertText', false, text);
  195.               });
Advertisement
Add Comment
Please, Sign In to add comment