Secondary Toot Button

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

目前为 2018-09-01 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Secondary Toot Button
  3. // @namespace http://github.com/yuzulabo
  4. // @version 1.2.3
  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 action = "document.getElementsByClassName('privacy-dropdown__value-icon')[0].click();"+
  30. "document.querySelector('.privacy-dropdown__option[data-index="+privacy_mode+"]').click();"+
  31. "document.querySelector('.compose-form__publish-button-wrapper button').click()";
  32.  
  33. const div_elem = document.createElement('div');
  34. div_elem.setAttribute('style', 'padding-top: 10px;margin-right: 10px');
  35. div_elem.innerHTML = '<button class="button button--block" style="padding: 0px 10px; height: 36px; line-height: 36px;" onclick="'+action+'"><i class="fa fa-fw fa-'+privacy_icon+'"></i></button>';
  36. form.insertBefore(div_elem, document.getElementsByClassName("compose-form__publish-button-wrapper")[0])
  37. }
  38.  
  39. window.onload = function () {
  40. generateButton();
  41. };
  42. })();