Secondary Toot Button

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

目前为 2019-03-07 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Secondary Toot Button
  3. // @namespace http://github.com/yuzulabo
  4. // @version 1.2.5
  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. // @license MIT License
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. const privacy_mode = "unlisted"; // 公開: public, 未収載: unlisted, 非公開: private, ダイレクト: direct
  18.  
  19. function generateButton() {
  20. const form = document.getElementsByClassName("compose-form__publish")[0];
  21. if (!form) return;
  22.  
  23. const privacy_icon =
  24. privacy_mode === "public" ? "globe" :
  25. privacy_mode === "unlisted" ? "unlock-alt" :
  26. privacy_mode === "private" ? "lock" :
  27. privacy_mode === "direct" ? "envelope" : null;
  28. if (!privacy_icon) return;
  29.  
  30. const div_elem = document.createElement('div');
  31. div_elem.setAttribute('style', 'padding-top: 10px;margin-right: 10px');
  32. div_elem.innerHTML = '<button class="button button--block" style="padding: 0px 10px; height: 36px; line-height: 36px;"><i class="fa fa-fw fa-'+privacy_icon+'"></i></button>';
  33. form.insertBefore(div_elem, document.getElementsByClassName("compose-form__publish-button-wrapper")[0]);
  34.  
  35. div_elem.addEventListener('click', postSecondary);
  36. }
  37.  
  38. function postSecondary() {
  39. document.getElementsByClassName('privacy-dropdown__value-icon')[0].click();
  40. document.querySelector('.privacy-dropdown__option[data-index='+privacy_mode+']').click();
  41. document.querySelector('.compose-form__publish-button-wrapper button').click();
  42. }
  43.  
  44. window.onload = function () {
  45. generateButton();
  46. };
  47. })();