Secondary Toot Button

セカンダリートゥートボタン (inspired by Glitch-soc)

  1. // ==UserScript==
  2. // @name Secondary Toot Button
  3. // @namespace http://github.com/yuzulabo
  4. // @version 1.3.0
  5. // @description セカンダリートゥートボタン (inspired by Glitch-soc)
  6. // @author nzws / ねじわさ
  7. // @match https://knzk.me/*
  8. // @match https://mastodon.cloud/*
  9. // @match https://friends.nico/*
  10. // @match https://pawoo.net/*
  11. // @match https://itabashi.0j0.jp/*
  12. // @match https://mstdn.jp/*
  13. // @match https://best-friends.chat/*
  14. // @match https://friends.cafe/*
  15. // @match https://fedibird.com/*
  16. // @license MIT License
  17. // ==/UserScript==
  18.  
  19. (function() {
  20. const privacy_mode = "unlisted"; // 公開: public, 未収載: unlisted, 非公開: private, ダイレクト: direct
  21.  
  22. function generateButton() {
  23. const form = document.getElementsByClassName("compose-form__publish")[0];
  24. if (!form) return;
  25.  
  26. const privacy_icon =
  27. privacy_mode === "public" ? "globe" :
  28. privacy_mode === "unlisted" ? "unlock-alt" :
  29. privacy_mode === "private" ? "lock" :
  30. privacy_mode === "direct" ? "envelope" : null;
  31. if (!privacy_icon) return;
  32.  
  33. const div_elem = document.createElement('div');
  34. div_elem.className = 'compose-form__publish-button-wrapper secondary';
  35. div_elem.style.marginRight = '10px';
  36. div_elem.innerHTML = '<button class="button button--block" style="padding: 0 10px"><i class="fa fa-fw fa-'+privacy_icon+'"></i></button>';
  37. form.insertBefore(div_elem, document.getElementsByClassName("compose-form__publish-button-wrapper")[0]);
  38.  
  39. div_elem.addEventListener('click', postSecondary);
  40. }
  41.  
  42. function postSecondary() {
  43. document.getElementsByClassName('privacy-dropdown__value-icon')[0].click();
  44. document.querySelector('.privacy-dropdown__option[data-index='+privacy_mode+']').click();
  45. document.querySelector('.compose-form__publish-button-wrapper:not(.secondary) button').click();
  46. }
  47.  
  48. window.onload = function () {
  49. generateButton();
  50. };
  51. })();