Guest User

Steemit EasyEdit

a guest
Sep 14th, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Steemit EasyEdit
  3. // @namespace   Steemit EasyEdit
  4. // @description Let's Make the Editor Great! (Again?)
  5. // @version     1
  6. // @author      https://steemit.com/@bitcoiner
  7. // @include     https://steemit.com/*
  8. // @grant       none
  9. // ==/UserScript==
  10.  
  11. var menu = document.getElementById("userscript-context-menu");
  12. if(!menu) {
  13.   var menu = document.body.appendChild(document.createElement("menu"));
  14.   menu.outerHTML = '<menu id="userscript-context-menu" type="context"><menuitem id="userscript-context-menuitem-easyedit" label="Steemit EasyEdit" icon="https://steemit.com/images/favicons/favicon-32x32.png"></menuitem></menu>';
  15. }
  16. else {
  17.   var menuitem = menu.appendChild(document.createElement("menuitem"));
  18.   menuitem.outerHTML = '<menuitem id="userscript-context-menuitem-easyedit" label="Steemit EasyEdit" icon="https://steemit.com/images/favicons/favicon-32x32.png"></menuitem>';
  19. }
  20.  
  21. var html = document.documentElement;
  22. html.setAttribute("contextmenu", "userscript-context-menu");
  23.  
  24. document.getElementById("userscript-context-menuitem-easyedit").addEventListener("click", onMenuClick, false);
  25.  
  26. function onMenuClick() {
  27.   setInterval(function() {
  28.     var vframe = document.getElementsByClassName("vframe")[0];
  29.     if(vframe) vframe.style.display = "block";
  30.     var edit = document.getElementsByClassName("public-DraftEditor-content");
  31.     if(edit.length) {
  32.       if(!edit[0].hasAttribute("hasAdded")) {
  33.         edit[0].setAttribute("hasAdded", "true");
  34.         if(top.editorHeight) edit[0].style.height = top.editorHeight;
  35.         else edit[0].style.height = "20em";
  36.         edit[0].style.overflowY = "scroll";
  37.         edit[0].style.overflowX = "auto";
  38.         edit[0].style.resize = "vertical";
  39.         edit[0].style.margin = "auto";
  40.         setTimeout(function() {
  41.           edit[0].style.margin = "";
  42.           setTimeout(function() {
  43.             if(top.editorScrollTop) edit[0].scrollTop = top.editorScrollTop;
  44.           }, 20)
  45.         }, 20);
  46.         edit[0].onscroll = function() {
  47.           top.editorScrollTop = this.scrollTop;
  48.         }
  49.       }
  50.       top.editorHeight = edit[0].style.height;
  51.     }
  52.   }, 500);
  53. }
Advertisement
Add Comment
Please, Sign In to add comment