tieba_float_editor

百度贴吧悬浮编辑窗

  1. // ==UserScript==
  2. // @name tieba_float_editor
  3. // @description 百度贴吧悬浮编辑窗
  4. // @include http://tieba.baidu.com/*
  5. // @exclude http://tieba.baidu.com/i/*
  6. // @exclude http://tieba.baidu.com/f/like*
  7. // @exclude http://tieba.baidu.com/club/*
  8. // @exclude http://tieba.baidu.com/shipin/*
  9. // @exclude http://tieba.baidu.com/bakan*
  10. // @exclude http://tieba.baidu.com/daquan*
  11. // @exclude http://tieba.baidu.com/f/tupian*
  12. // @exclude http://tieba.baidu.com/tb/*
  13. // @exclude http://tieba.baidu.com/*postBrowserBakan*
  14. // @icon http://tb.himg.baidu.com/sys/portraitn/item/4e2ed7f8bbb3d4f2c2d2bb21
  15. // @author congxz6688
  16. // @version 2013.6.8.0
  17. // @namespace https://greatest.deepsurf.us/scripts/158
  18. // ==/UserScript==
  19.  
  20. var replyCss = "";
  21. replyCss += "#edit_parent .tb-editor-toolbar>span{width:30px !important;}";
  22. replyCss += ".idisk{margin-right:16px !important;}";
  23. replyCss += ".editor_banned_tip_info{position:relative; top:-80px !important;}";
  24. replyCss += ".pt_submit{padding:0 !important; margin:0 !important;}";
  25. replyCss += ".tb-editor-wrapper>.tb-editor-overlay{position:absolute;}";
  26. replyCss += ".insertsmiley_holder>.tb-editor-overlay{ position:relative !important; top:-360px !important;}";
  27. replyCss += "#signNameWrapper{margin:0px 0px -2px 0px !important;}";
  28. replyCss += "#footer,.new_tiezi_tip,.subTip,.e_inter_wrapper,td[valign='top'],#edit_parent>table>tbody>tr>td:first-child,.wapapp_adv{display:none !important;}";
  29. replyCss += ".editor_users{padding:0 !important; margin:0px !important;}";
  30. replyCss += ".subbtn_bg_hover{margin-right:5px !important; height:26px !important; line-height:26px !important;}";
  31. replyCss += ".sfloatEditor{padding-bottom:1px !important; border:3px double grey; width:360px; position:fixed !important; bottom:-30px !important; left:500px !important;z-index:998 !important;background-color:#E7EAEB}";
  32. replyCss += ".floatEditor{padding-bottom:1px !important; border:3px double grey; width:635px; position:fixed !important; bottom:-30px !important; left:500px !important;z-index:998 !important;background-color:#E7EAEB}";
  33. replyCss += "#OaCbutton{display:none;}#panel,#iColorPicker{position:fixed;bottom:0;left:500px}";
  34. //replyCss += "#edit_parent .tb-editor-editarea{height:240px !important;}";//此句用于固定编辑窗高度,需要的话,取消最前面的//。
  35. GM_addStyle(replyCss);
  36.  
  37. var smallEditorCss = "";
  38. smallEditorCss += "body{margin-bottom:260px !important;}";
  39. smallEditorCss += "#edit_parent .tb-editor-toolbar,#signNameWrapper,.pt_submit,#edit_parent tr:nth-child(3),.pt_submit,#edit_parent tr:nth-child(4),#edit_parent tr:nth-child(5),#edit_parent tr:nth-child(6),#edit_parent tr:nth-child(7),#edit_parent tr:nth-child(8){display:none !important;}";
  40. smallEditorCss += "#edit_parent *{max-width:360px !important;}";
  41. smallEditorCss += ".tb-editor-editarea{max-height:266px !important; min-height:24px !important;}";
  42. smallEditorCss += ".edit_title_field{padding:0px !important; margin:0px 0px -5px 0px !important;}";
  43.  
  44. var normalEditorCss = "";
  45. normalEditorCss += "body{margin-bottom:360px !important;}";
  46. normalEditorCss += "#edit_parent *:not(.ffs_s_tab_content):not(.s_tab_content){max-width:635px !important}";
  47. normalEditorCss += ".tb-editor-editarea{max-height:266px !important; min-height:50px !important;}";
  48. normalEditorCss += ".edit_title_field{padding:0px 3px!important; margin:0px 0px -5px 0px !important;}";
  49.  
  50. function openOrclose(e) {
  51. if(window.getSelection()!=""){
  52. return;
  53. }else{
  54. if (document.getElementById("OaCbutton").getAttribute("status") == "close") {
  55. document.getElementById("floatEditorCSS").innerHTML = normalEditorCss;
  56. document.getElementById("edit_parent").setAttribute("class", "floatEditor");
  57. document.getElementById("OaCbutton").setAttribute("status", "open");
  58. document.querySelector("#edit_parent .tb-editor-editarea").removeAttribute("title");
  59. return;
  60. }
  61. if (document.getElementById("OaCbutton").getAttribute("status") == "open") {
  62. document.getElementById("floatEditorCSS").innerHTML = smallEditorCss;
  63. document.getElementById("edit_parent").setAttribute("class", "sfloatEditor");
  64. document.getElementById("OaCbutton").setAttribute("status", "close");
  65. return;
  66. }
  67. }
  68. }
  69.  
  70. var OaCbutton = document.createElement("span");
  71. OaCbutton.id = "OaCbutton";
  72. OaCbutton.setAttribute("status", 'close');
  73. OaCbutton.innerHTML = "";
  74. document.getElementById("edit_parent").parentNode.insertBefore(OaCbutton, document.getElementById("edit_parent"));
  75.  
  76. document.getElementById("edit_parent").setAttribute("class", "sfloatEditor");//初始缩态
  77.  
  78. var floatEditorCSS = document.createElement("style");
  79. floatEditorCSS.id = "floatEditorCSS";
  80. floatEditorCSS.type = "text/css";
  81. floatEditorCSS.innerHTML = smallEditorCss;
  82. document.head.appendChild(floatEditorCSS);
  83.  
  84. var editorInputCSS = document.createElement("style");
  85. editorInputCSS.id = "editorInputCSS";
  86. editorInputCSS.type = "text/css";
  87. editorInputCSS.innerHTML = "#title1{display:none !important;}";
  88. document.head.appendChild(editorInputCSS);
  89.  
  90. function inputDon(){
  91. document.head.removeChild(document.getElementById("editorInputCSS"));
  92. document.querySelector("#edit_parent .tb-editor-editarea").removeEventListener("click", inputDon, false);
  93. }
  94.  
  95. document.querySelector("#edit_parent .tb-editor-editarea").setAttribute("title", "单击可展开标题栏,双击可展开或缩小编辑窗口。");
  96. document.querySelector("#edit_parent .tb-editor-editarea").removeAttribute("style");
  97. document.querySelector("#edit_parent .tb-editor-editarea").addEventListener("dblclick", openOrclose, false);
  98. document.querySelector("#edit_parent .tb-editor-editarea").addEventListener("click", inputDon, false);
  99.  
  100. //调整编辑工具弹出位置
  101. var bottwidth=document.getElementById("title1")?-30:0;
  102. var upSavewid=document.getElementById("title1")?63:33;
  103. document.querySelector(".image:not(.open)").addEventListener("click", function(){GM_addStyle(".tb-editor-wrapper>.tb-editor-overlay:not(.idisk_holder){top:" + (bottwidth + Math.min(upSavewid,document.querySelector("#edit_parent").clientHeight-420)) + "px !important; left:10px !important;}")}, false);
  104. document.querySelector(".flash:not(.open)").addEventListener("click", function(){GM_addStyle(".tb-editor-wrapper>.tb-editor-overlay:not(.idisk_holder){top:" + (bottwidth + Math.min(upSavewid,document.querySelector("#edit_parent").clientHeight-160)) + "px !important; left:20px !important;}")}, false);
  105. document.querySelector(".music:not(.open)").addEventListener("click", function(){GM_addStyle(".tb-editor-wrapper>.tb-editor-overlay:not(.idisk_holder){top:" + (bottwidth + Math.min(upSavewid,document.querySelector("#edit_parent").clientHeight-405)) + "px !important; left:30px !important;}")}, false);
  106. document.querySelector(".smiley:not(.open)").addEventListener("click", function(){GM_addStyle(".tb-editor-wrapper>.tb-editor-overlay:not(.idisk_holder){top:" + (bottwidth + Math.min(upSavewid,document.querySelector("#edit_parent").clientHeight-360)) + "px !important; left:80px !important;}")}, false);
  107. document.querySelector(".picasso:not(.open)").addEventListener("click", function(){GM_addStyle(".tb-editor-wrapper>.tb-editor-overlay:not(.idisk_holder){top:" + (bottwidth + Math.min(upSavewid,document.querySelector("#edit_parent").clientHeight-375)) + "px !important; left:50px !important;}")}, false);
  108.  
  109. //兼容复杂取色器之图片化脚本
  110. if(document.querySelector("#colorPreview,#panel")){
  111. document.querySelector("#colorPreview,#panel").removeAttribute("style");
  112. }