2
0

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 5 years have passed since last update.

Yahooニュースの提供元サイトにジャンプするブックマークレット

Last updated at Posted at 2017-01-17
javascript:location.href="http://www.google.com/search?btnI=I%27m+Feeling+Lucky&q="+document.querySelector('h1').innerText+"+-site:yahoo.co.jp"

提供元 ←をブックマークにドラッグ&ドロップしてください。

ソース解説

1.ニュースのタイトルを取得します。

Yahooニュースではh1タグにタイトルが設定されているので、querySelectorでh1タグを選択すればタイトルが取得できます。

document.querySelector('h1').innerText

2.google検索にリクエストします。

location.hrefを書き換えて、google検索に遷移させます。

location.href="http://www.google.com/search"

google検索の仕様

getパラメータでqに検索文字列を渡せます。
http://www.google.com/search?q=qiita+-site:qiita.com

検索文字列に-site:qiita.comを付加すると、ドメインがqiita.comを除外した結果が帰ってきます。

btnIにI'm Feeling Luckyを渡すと、検索のトップのURLにリダイレクトします。
http://www.google.com/search?q=I%27m+Feeling+Lucky&btnI=I%27m+Feeling+Lucky

2
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?