Last active
November 12, 2018 10:50
-
-
Save mpyw/0561d066882501f093353f96e4fb4b4c to your computer and use it in GitHub Desktop.
Qiita Trend Eliminator
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
// ==UserScript== | |
// @name Qiita Trend Eliminator | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description https://qiita.com/ を https://qiita.com/tag-feed にいい感じに置き換える | |
// @author mpyw | |
// @match https://qiita.com/* | |
// @grant none | |
// ==/UserScript== | |
(() => { | |
'use strict'; | |
// 他サイトからトレンドへの流入であればタグフィードに強制移動 | |
if (location.pathname === '/' && (!document.referrer || new URL(document.referrer).host !== 'qiita.com')) { | |
location.replace('/tag-feed'); | |
} | |
// ヘッダーの Qiita ロゴの向き先をタグフィードに変更 | |
const header = document.querySelector('a.st-Header_logo'); | |
header.href = '/tag-feed'; | |
// トレンドをメニュー最下部に,タグフィードはメニュー最上部に | |
// for (const menu of [ | |
// document.querySelectorAll('#globalHeader .st-Header_dropdown')[1], | |
// document.querySelector('.p-home_menu'), | |
// ]) { | |
// const tagFeed = menu.removeChild(menu.children[2]); | |
// const trend = menu.removeChild(menu.children[0]); | |
// menu.prepend(tagFeed); | |
// menu.append(trend); | |
// } | |
})(); |
L.15
const header = document.querySelector('a.st-Header_logo');
これでTOPページと記事詳細に両対応
thx!
L.18
TOPページ系と詳細ページの中身は作りが違うので、やる必要ないとおもう。
必須機能じゃないしね。
確かにページがちらつくのでちょっと微妙かも
L.30
これは用途からして先頭に持ってくるべき
ご尤も
修正後のL.25は
必要性があるかはさておき、ヘッダーの左側が.st-Header_start
で多分全てのページ共通だから、
document.querySelectorAll('.st-Header_start .st-Header_dropdown')[1],
に変更すれば引っ掛けられそう(未確認)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
L.15
const header = document.querySelector('a.st-Header_logo');
これでTOPページと記事詳細に両対応
L.18
TOPページ系と詳細ページの中身は作りが違うので、やる必要ないとおもう。
必須機能じゃないしね。
L.30
これは用途からして先頭に持ってくるべき