Created
May 31, 2023 15:19
-
-
Save mosaicer/d9304b3f468c45cc07e14b7528e795e5 to your computer and use it in GitHub Desktop.
Eventernoteに参加ツイートボタンを表示する。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let hashtags = 'eventernote'; | |
| const tds = [... document.getElementsByClassName('gb_events_info_table')[0].querySelectorAll('td')]; | |
| for (let i = 0; i < tds.length; i++) { | |
| if (tds[i].textContent === 'Twitterハッシュタグ') { | |
| hashtags += ` ${tds[i+1].textContent.replaceAll('#', '')}`; | |
| break; | |
| } | |
| } | |
| const title = document.getElementsByClassName('gb_events_detail_title')[0].children[0].textContent; | |
| const url = `https://twitter.com/intent/tweet?hashtags=${hashtags.replaceAll(' ', ',')}&text=${title}に参加します。&url=${location.href}` | |
| const p = document.createElement('p'); | |
| p.innerHTML = `<p class="center"><a href="${encodeURI(url)}" class="btn btn-large btn-success"><i class="icon icon-share icon-white"></i>参加ツイートする</a></p>`; | |
| document.getElementById('entry_area').appendChild(p); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment