Secondary Toot Button

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

目前为 2018-10-12 提交的版本。查看 最新版本

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