Last active
July 24, 2022 14:04
-
-
Save motsu0/0bc9113f90203d043448121c3e4bdee2 to your computer and use it in GitHub Desktop.
This file contains 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
.settings-row{ | |
display: flex; | |
flex-direction: column; | |
align-items: flex-start; | |
row-gap: 8px; | |
padding: 12px; | |
margin: 12px 0; | |
background-color: #eee; | |
} | |
.label-input{ | |
font-weight: bold; | |
} | |
.input-text,.input-date,.input-number,.select{ | |
display: block; | |
box-sizing: border-box; | |
width: 100%; | |
height: 40px; | |
padding-left: 8px; | |
} | |
.cb{ | |
margin-right: 4px; | |
vertical-align: middle; | |
} | |
.label-cb{ | |
display: block; | |
cursor: pointer; | |
} | |
/* */ | |
#bt-tweet{ | |
display: block; | |
margin: 20px auto; | |
border: none; | |
border-radius: 8px; | |
background-color: #1d9bf0; | |
font-family: 'Helvetica Neue',Arial,sans-serif; | |
text-decoration: none; | |
color: #fff; | |
cursor: pointer; | |
} | |
.bt-tweet__img{ | |
width: 32px; | |
margin: 8px 12px; | |
vertical-align: middle; | |
} | |
.bt-tweet__text{ | |
margin-right: 12px; | |
} |
This file contains 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
<form id="form"> | |
<div class="settings"> | |
<div class="settings-row"> | |
<div class="label-input">検索ワード</div> | |
<input type="text" id="input-keyword" class="input-text" placeholder="検索したい単語"> | |
</div> | |
<div class="settings-row"> | |
<div class="label-input">特定アカウントからのツイート[from:screen_name]</div> | |
<input type="text" id="input-from" class="input-text" placeholder="@◯◯◯◯◯"> | |
</div> | |
<div class="settings-row"> | |
<div class="label-input">特定アカウントからのツイートを除外[-from:screen_name]</div> | |
<input type="text" id="input-from-minus" class="input-text" placeholder="@◯◯◯◯◯"> | |
</div> | |
<div class="settings-row"> | |
<div class="label-input">特定アカウントへのツイート[to:screen_name]</div> | |
<input type="text" id="input-to" class="input-text" placeholder="@◯◯◯◯◯"> | |
</div> | |
<div class="settings-row"> | |
<div class="label-input">特定アカウントへのツイートを除外[-to:screen_name]</div> | |
<input type="text" id="input-to-minus" class="input-text" placeholder="@◯◯◯◯◯"> | |
</div> | |
<div class="settings-row"> | |
<div class="label-input">日付指定(◯◯日以降)[since:XXXX-XX-XX]</div> | |
<input type="date" id="input-since" class="input-date"> | |
<label class="label-cb"> | |
<input type="checkbox" id="cb-since" class="cb">日付指定(◯◯以降)を有効にする | |
</label> | |
</div> | |
<div class="settings-row"> | |
<div class="label-input">日付指定(◯◯日以前)[until:XXXX-XX-XX]</div> | |
<input type="date" id="input-until" class="input-date"> | |
<label class="label-cb"> | |
<input type="checkbox" id="cb-until" class="cb">日付指定(◯◯以前)を有効にする | |
</label> | |
</div> | |
<div class="settings-row"> | |
<div class="label-input">画像や動画を含むツイート[filter:◯◯◯]</div> | |
<select id="sel-filter-media" class="select"> | |
<option value="none">-</option> | |
<option value="images">画像を含む</option> | |
<option value="videos">動画を含む</option> | |
<option value="media">画像か動画を含む</option> | |
<option value="images-minus">画像を含まない</option> | |
<option value="videos-minus">動画を含まない</option> | |
<option value="media-minus">画像と動画を含まない</option> | |
</select> | |
</div> | |
<div class="settings-row"> | |
<div class="label-input">URLを含むツイート[filter:◯◯◯]</div> | |
<select id="sel-filter-links" class="select"> | |
<option value="none">-</option> | |
<option value="links">URLを含む</option> | |
<option value="links-minus">URLを含まない</option> | |
</select> | |
</div> | |
<div class="settings-row"> | |
<div class="label-input">RT数の最小値[min_retweets:XX]</div> | |
<input type="number" id="input-rt" class="input-number" placeholder="100"> | |
</div> | |
<div class="settings-row"> | |
<div class="label-input">いいね数の最小値[min_faves:XX]</div> | |
<input type="number" id="input-fav" class="input-number" placeholder="100"> | |
</div> | |
</div> | |
<button id="bt-tweet"> | |
<img src="/img/icon/twitter-white.svg" alt="ツイッターの白い鳥のアイコン" class="bt-tweet__img"> | |
<span class="bt-tweet__text">検索</span> | |
</button> | |
</form> |
This file contains 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
const el_form = document.getElementById('form'); | |
const inputs = { | |
keyword: document.getElementById('input-keyword'), | |
from: document.getElementById('input-from'), | |
from_minus: document.getElementById('input-from-minus'), | |
to: document.getElementById('input-to'), | |
to_minus: document.getElementById('input-to-minus'), | |
since: document.getElementById('input-since'), | |
until: document.getElementById('input-until'), | |
rt: document.getElementById('input-rt'), | |
fav: document.getElementById('input-fav') | |
}; | |
const cb_since = document.getElementById('cb-since'); | |
const cb_until = document.getElementById('cb-until'); | |
const sel_filter_media = document.getElementById('sel-filter-media'); | |
const sel_filter_links = document.getElementById('sel-filter-links'); | |
const bt_tweet = document.getElementById('bt-tweet'); | |
el_form.addEventListener('submit',e=>{ | |
e.preventDefault(); | |
openLink(); | |
}); | |
function openLink(){ | |
const array_text = []; | |
if(inputs.keyword.value!=''){ | |
array_text.push(inputs.keyword.value); | |
} | |
if(inputs.from.value!=''){ | |
array_text.push('from:'+inputs.from.value.replace('@','')); | |
} | |
if(inputs.from_minus.value!=''){ | |
array_text.push('-from:'+inputs.from_minus.value.replace('@','')); | |
} | |
if(inputs.to.value!=''){ | |
array_text.push('to:'+inputs.to.value.replace('@','')); | |
} | |
if(inputs.to_minus.value!=''){ | |
array_text.push('-to:'+inputs.to_minus.value.replace('@','')); | |
} | |
if(cb_since.checked){ | |
if(inputs.since.value!=''){ | |
array_text.push('since:'+inputs.since.value); | |
} | |
} | |
if(cb_until.checked){ | |
if(inputs.until.value!=''){ | |
array_text.push('until:'+inputs.until.value); | |
} | |
} | |
switch(sel_filter_media.value){ | |
case 'none': | |
break; | |
case 'images': | |
case 'videos': | |
case 'media': | |
array_text.push('filter:'+sel_filter_media.value); | |
break; | |
default: | |
array_text.push('-filter:'+sel_filter_media.value.replace('-minus','')); | |
break; | |
} | |
switch(sel_filter_links.value){ | |
case 'none': | |
break; | |
case 'links': | |
array_text.push('filter:'+sel_filter_links.value); | |
break; | |
default: | |
array_text.push('-filter:'+sel_filter_links.value.replace('-minus','')); | |
break; | |
} | |
if(inputs.rt.value!=''){ | |
array_text.push('min_retweets:'+inputs.rt.value); | |
} | |
if(inputs.fav.value!=''){ | |
array_text.push('min_faves:'+inputs.fav.value); | |
} | |
const params = new URLSearchParams(); | |
params.append('q',array_text.join(' ')); | |
const url = 'https://twitter.com/search?' + params.toString(); | |
window.open(url,null,'noreferrer=yes'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment