LoginSignup
2
1

More than 3 years have passed since last update.

Growiの編集時に自動でslack通知ボックスにチェックを入れる

Last updated at Posted at 2020-11-25

前提

・SlackとGrowiの連携はすませてある。
・使用者が通知ボックスにチェックを入れる習慣がないが、一方でページの編集・作製は通知したい。

すでにある取り組み

https://qiita.com/ymm1x/items/15278f6ef1794b718955
https://qiita.com/nao-guitarist/items/82ed2ed7cb2e9eacd08a

なぜ改めて記事を書いた?

  • Growiの仕様変更により要素の指定先が変わっている。(これだけなら編集リクエストすれば良いのだけど)
  • Qiitaに記事を初めて書いてみたかった。(そのついでにという感じ)
  • Growiの記事もっと欲しかった。(ささやかなあがき)

結論

管理者アカウントでログイン後、カスタムスリプト内に以下を書く。

admin/customize
function slackPostTrue() {
  document.querySelector('div label input').closest('label').click()
  document.querySelector('div label input').checked = true
}

window.addEventListener('keypress', (e) => {
  if( location.hash == '#edit' && document.querySelector('div label input').checked != true ) {
    slackPostTrue()
  }
})

@nao-guitaristさんの記事 での指定要素を'div label input'に替えただけ。
ymm1xさんの記事 でも同様に、かつての要素位置'#save-page-controls input[type=checkbox]'を変更すればOK.

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1