0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Twitterのリツート前後1時間のTweetを取得するためのBookmarklet

Posted at
bookmarklet.js
{
// 前後1時間
const toUTC = (dt) => {
    const isoString = dt.toISOString();
    return isoString.replace('T','_').split('.')[0] + '_UTC';
}    
const dt = document.querySelectorAll('time')[0].dateTime;
const t = Date.parse(dt);
const anHourAgo = new Date(t - (3600 * 1000));
const anHourLate = new Date(t + (3600 * 1000));
console.log(`${anHourAgo.toLocaleString()}${anHourLate.toLocaleString()}`);
const url = document.querySelectorAll('link[rel=canonical]')[0].href;
const userName = url.split('/')[3];
const queryValue = `from:${userName} since:${toUTC(anHourAgo)} until:${toUTC(anHourLate)} include:nativeretweets`;
const queryEncoded = encodeURIComponent(queryValue);
const href = `https://twitter.com/search?q=${queryEncoded}&src=typed_query&f=top`;
document.location.href = href; 
}
0
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?