Quaternary Toot Button

クオータナリトゥートボタン (意味不明すぎるネタ)

目前为 2019-05-11 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Quaternary Toot Button
  3. // @namespace http://github.com/yuzulabo
  4. // @version 1.0.0
  5. // @description クオータナリトゥートボタン (意味不明すぎるネタ)
  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. // @license MIT License
  15. // ==/UserScript==
  16.  
  17. (function() {
  18. function generateButton(privacy_mode) {
  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(privacy_mode));
  35. }
  36.  
  37. function postSecondary(privacy_mode) {
  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. ["direct", "private", "unlisted"].forEach(mode => generateButton(mode));
  45. };
  46. })();