rearrange-O-Don

more useful space in Mastodon

安装此脚本
作者推荐脚本

您可能也喜欢resize-o-don

安装此脚本
  1. // ==UserScript==
  2. // @name rearrange-O-Don
  3. // @license DWTFYW
  4. // @namespace http://pureandapplied.com.au/composeToFirstColumn
  5. // @version 0.1.5
  6. // @description more useful space in Mastodon
  7. // @author stib
  8. // @match https://*.social/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=aus.social
  10. // @run-at document-start
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. const postButtonText = "Post!"; //change to whatever you want you sick freaks.
  16. // Identify the source and destination containers using appropriate selectors
  17. let elementList = [
  18. // listed in reverse order, bcs they get inserted at the top each time
  19. 'form.compose-form',
  20. 'div.navigation-bar',
  21. 'div.search',
  22. 'nav.drawer__header',
  23. ];
  24. window.addEventListener('load', reorganiseODon);
  25.  
  26. function reorganiseODon(){
  27. // first column is the target for where we're moving stuff
  28. const destinationContainer = document.querySelector('div.column');
  29. console.log("hacking the Mastodon UI to make things more compact");
  30. if (destinationContainer){
  31.  
  32. for (let i = 0; i < elementList.length; i++){
  33. const fc = destinationContainer.firstChild;
  34. console.log(fc);
  35. const src = document.querySelector(elementList[i]);
  36. if (src && fc) {
  37. // remove superfluous padding
  38. src.style.paddingLeft = 0;
  39. src.style.paddingRight = 0;
  40. src.style.paddingTop = 0;
  41. // move to the destination column
  42. destinationContainer.insertBefore(src, fc);
  43. }
  44. }
  45. }
  46. //hide the empty column
  47. const origColumn = document.querySelector('div.drawer');
  48. origColumn.style.display = 'none';
  49. //give a little bit of space to the first column
  50. destinationContainer.style.paddingLeft = "10px";
  51. //move the toot button inside the post section
  52. const tootButt = document.querySelector('button.button--block');
  53. tootButt.style.paddingTop = 0;
  54. tootButt.style.paddingBottom = 0;
  55. tootButt.innerText = postButtonText;
  56. const buttBar = document.querySelector('div.compose-form__buttons-wrapper');
  57. buttBar.appendChild(tootButt);
  58. //remove the empty old toot button div
  59. document.querySelector('div.compose-form__publish').style.display = 'none';
  60. }
  61. })();