Last active
January 1, 2020 18:05
-
-
Save am4dr/e403980f0c6788d7979a537923afb1d8 to your computer and use it in GitHub Desktop.
ユーザースクリプト置き場
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 <title> | |
// @namespace https://gist.github.com/am4dr/e403980f0c6788d7979a537923afb1d8 | |
// @version 0.0.1 | |
// @description <description> | |
// @author am4dr | |
// @updateURL https://gist.github.com/am4dr/e403980f0c6788d7979a537923afb1d8/raw/<name>.user.js | |
// @match <url *://*> | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
})(); |
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 dアニメストア - 各アニメページ - 表示話数変更 | |
// @namespace https://gist.github.com/am4dr/e403980f0c6788d7979a537923afb1d8 | |
// @version 0.1 | |
// @description 各アニメのページで一度に表示される話数を変更する。(14でだいたい1ページあるいは2ページに収めたい) | |
// @author am4dr | |
// @updateURL https://gist.github.com/am4dr/e403980f0c6788d7979a537923afb1d8/raw/dAnimeStore_animepage_num-of-stories.user.js | |
// @match https://anime.dmkt-sp.jp/animestore/ci_pc* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const slideSelector = '.episodeContainer.itemWrapper.swiper-wrapper > .swiper-slide'; | |
const slides = Array.from(document.querySelectorAll(slideSelector)); | |
const items = slides.reduce((acc, node) => acc.concat(...node.querySelectorAll('.itemModule.list')), []); | |
const count = 14; | |
for (var i = 0; i*count < items.length; ++i) { | |
items.slice(i*count, (i+1)*count).forEach((it) => slides[i].appendChild(it)); | |
} | |
})(); |
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 dアニメストア - 次の1話 - 作品ページへリンク | |
// @namespace https://gist.github.com/am4dr/e403980f0c6788d7979a537923afb1d8 | |
// @version 0.1 | |
// @description 次の1話の「詳しく見る」リンクを作品のトップページヘのリンクに置換する | |
// @author am4dr | |
// @updateURL https://gist.github.com/am4dr/e403980f0c6788d7979a537923afb1d8/raw/dAnimeStore_next_title-link.user.js | |
// @match https://anime.dmkt-sp.jp/animestore/mp_viw_pc* | |
// @grant none | |
// ==/UserScript== | |
/* 長いタイトルがサムネにはみ出す */ | |
function replaceLink(story) { | |
'use strict'; | |
const titleHeader = story.querySelector("h2.line1"); | |
const title = titleHeader.getElementsByTagName("span")[0].textContent; | |
titleHeader.style.display = "none"; | |
const detailAnchor = story.querySelector(".detail a"); | |
detailAnchor.childNodes[0].textContent = title; | |
detailAnchor.href = detailAnchor.href.replace(/&partId=\d+/, ''); | |
} | |
(function() { | |
'use strict'; | |
const stories = document.querySelectorAll(".itemModule.list section"); | |
stories.forEach(replaceLink); | |
})(); |
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 dアニメストア - 次の1話 - 更新曜日表示 | |
// @namespace https://gist.github.com/am4dr/e403980f0c6788d7979a537923afb1d8 | |
// @version 0.1.3 | |
// @description 次の1話のページで更新曜日を推測して表示する。更新日、更新曜日、配信期間ありに'update-date', ('update-day-*', 'until-update-day-*'), 'has-deadline'をつける。 | |
// @author am4dr | |
// @updateURL https://gist.github.com/am4dr/e403980f0c6788d7979a537923afb1d8/raw/dAnimeStore_next_update-day.user.js | |
// @match https://anime.dmkt-sp.jp/animestore/mp_viw_pc* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const currentDate = new Date(); | |
const daysString = ["日", "月", "火", "水", "木", "金", "土"]; | |
const tagList = document.querySelectorAll(".itemModule.list ul.option"); | |
const dateReg = /(\d+)\/(\d+) 話追加/; | |
function getDate(str) { | |
const date = dateReg.exec(str); | |
return date ? date.slice(1,3) : date; | |
} | |
function getUpdateDateTag(tagList) { | |
const tags = Array.from(tagList.getElementsByTagName('li')); | |
const updateDateTag = tags.find(tag => tag.textContent && getDate(tag.textContent)); | |
if (!updateDateTag) return updateDateTag; | |
else return { | |
'tag': updateDateTag, | |
'date': getDate(updateDateTag.textContent) | |
}; | |
} | |
function calcUpdateDay(month, day) { | |
var addedYear = currentDate.getFullYear(); | |
if (month > currentDate.getMonth() + 1) { | |
--addedYear; | |
} | |
const addedDate = new Date(addedYear, month - 1, day); | |
return addedDate.getDay(); | |
} | |
tagList.forEach(tag => { | |
const updateDateTag = getUpdateDateTag(tag); | |
if (updateDateTag) { | |
updateDateTag.tag.classList.add('updated-date'); | |
const updateDay = calcUpdateDay(...updateDateTag.date); | |
const diffDay = (updateDay - currentDate.getDay() + 7) % 7; | |
const dayTag = document.createElement('li'); | |
dayTag.classList.add(`update-day-${updateDay}`, `until-update-day-${diffDay}`); | |
dayTag.textContent = daysString[updateDay]; | |
tag.insertBefore(dayTag, updateDateTag.tag); | |
} | |
for (var li of tag.getElementsByTagName('li')) { | |
if (li && li.textContent === '配信期間あり') { | |
li.classList.add('has-deadline'); | |
} | |
} | |
}); | |
})(); |
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 小説家になろう - ブクマ - 完結済みかを目印 | |
// @namespace https://gist.github.com/am4dr/e403980f0c6788d7979a537923afb1d8 | |
// @version 0.1.2 | |
// @description ブックマークページにて完結済みならcompletedをさもなくばnot-completedをfavnovelに対して付与する | |
// @author am4dr | |
// @updateURL https://gist.github.com/am4dr/e403980f0c6788d7979a537923afb1d8/raw/syosetu_bookmarks_complete-state.user.js | |
// @match *://syosetu.com/favnovelmain*/list/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const novels = document.getElementsByClassName('favnovel'); | |
for (const novel of novels) { | |
const no = novel.getElementsByClassName('no'); | |
if (no.length === 0) { continue; } | |
const content = no[0].textContent; | |
if (content.includes('最終')) { | |
novel.classList.add('completed'); | |
} | |
else { | |
novel.classList.add('not-completed'); | |
} | |
} | |
})(); |
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 小説家になろう - ブクマ - 最終更新日を目印 | |
// @namespace https://gist.github.com/am4dr/e403980f0c6788d7979a537923afb1d8 | |
// @version 0.1.2 | |
// @description ブックマークページにて最終更新が1年前ならlast-update-12m、半年前ならlast-update-6mをfavnovelに対して付与する | |
// @author am4dr | |
// @updateURL https://gist.github.com/am4dr/e403980f0c6788d7979a537923afb1d8/raw/syosetu_bookmarks_last-update.user.js | |
// @match *://syosetu.com/favnovelmain*/list/* | |
// @grant none | |
// ==/UserScript== | |
/* 判定の粗さは日くらい */ | |
(function() { | |
'use strict'; | |
/* テキスト例: 更新日:2017/05/25 23:28 */ | |
const reg = /更新日:(\d+)\/(\d+)\/(\d+)/; | |
function getDate(str) { | |
const date = reg.exec(str); | |
if (!date) { return date; } | |
return Date.UTC(date[1], date[2] - 1, date[3]); | |
} | |
const now_millis = Date.now(); | |
const month_millis = 60 * 60 * 24 * 30 * 1000; | |
const novels = document.getElementsByClassName('favnovel'); | |
for (const novel of novels) { | |
const info = novel.getElementsByClassName('info'); | |
if (info.length === 0) { continue; } | |
const content = info[0].getElementsByTagName('p')[0].textContent; | |
const date = getDate(content); | |
if (!date) { continue; } | |
const elapse = now_millis - date; | |
if (elapse >= 12*month_millis) { | |
novel.classList.add('last-update-12m'); | |
} | |
else if (elapse >= 6*month_millis) { | |
novel.classList.add('last-update-6m'); | |
} | |
else if (elapse <= month_millis) { | |
novel.classList.add('last-update-1m'); | |
} | |
} | |
})(); |
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 小説家になろう - ブクマ - 更新の有無を目印 | |
// @namespace https://gist.github.com/am4dr/e403980f0c6788d7979a537923afb1d8 | |
// @version 0.1.3 | |
// @description ブックマークページにて更新があれば.has-updateを、なければno-updateを、未読のものにはnew-novelをfavnovelに対して付与する | |
// @author am4dr | |
// @updateURL https://gist.github.com/am4dr/e403980f0c6788d7979a537923afb1d8/raw/syosetu_bookmarks_update-state.user.js | |
// @match *://syosetu.com/favnovelmain*/list/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const novels = document.getElementsByClassName('favnovel'); | |
for (const novel of novels) { | |
const no = novel.getElementsByClassName('no'); | |
if (no.length === 0) { continue; } | |
const aTags = no[0].getElementsByTagName('a'); | |
if (!aTags || aTags.length === 0) { | |
continue; | |
} | |
else if (aTags.length === 1) { | |
novel.classList.add('new-novel'); | |
} | |
else if (aTags.length === 2) { | |
if (aTags[0].href !== aTags[1].href) { | |
novel.classList.add('has-update'); | |
} | |
else { | |
novel.classList.add('no-update'); | |
} | |
} | |
} | |
})(); |
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 twitpic download button | |
// @namespace https://gist.github.com/am4dr/e403980f0c6788d7979a537923afb1d8 | |
// @version 0.2.0 | |
// @description 画像のみのページでダウンロードリンクを追加する | |
// @author am4dr | |
// @updateURL https://gist.github.com/am4dr/e403980f0c6788d7979a537923afb1d8/raw/twimg_dl_link.user.js | |
// @match *://pbs.twimg.com/media/* | |
// @grant none | |
// ==/UserScript== | |
class LinkMenu { | |
constructor(text, link, config) { | |
this.text = text; | |
this.link = link; | |
this.config = config; | |
} | |
createElement() { | |
const a = document.createElement("a"); | |
a.style.marginLeft = "0.5em"; | |
a.style.marginRight = "0.5em"; | |
a.href = this.link; | |
a.innerText = this.text; | |
if (this.config) { | |
this.config(a); | |
} | |
return a; | |
} | |
} | |
class MenuBar { | |
constructor() { | |
this.menus = []; | |
} | |
createElement() { | |
const bar = document.createElement("div"); | |
this.menus.forEach(menu => bar.appendChild(menu.createElement())); | |
return bar; | |
} | |
addMenu(menu) { | |
this.menus.push(menu); | |
} | |
} | |
function setDownload(a) { | |
'use strict'; | |
a.download = ''; | |
return a; | |
} | |
(function() { | |
'use strict'; | |
const menu_bar = new MenuBar(); | |
menu_bar.addMenu(new LinkMenu("DL", document.URL, setDownload)); | |
if (document.URL.match(/^.*orig$/)) { | |
} | |
else { | |
const orig_url = document.URL.replace(/name=.+$/, 'name=orig'); | |
menu_bar.addMenu(new LinkMenu("DL:orig", orig_url, setDownload)); | |
menu_bar.addMenu(new LinkMenu("GoTo:orig", orig_url)); | |
} | |
const menu_bar_elm = menu_bar.createElement(); | |
menu_bar_elm.style.backgroundColor = "rgb(200, 200, 200)"; | |
menu_bar_elm.style.fontWeight = "bold"; | |
menu_bar_elm.style.position = "fixed"; | |
menu_bar_elm.style.top = 0; | |
menu_bar_elm.style.left = 0; | |
menu_bar_elm.style.display = "block"; | |
document.body.insertBefore(menu_bar_elm, document.getElementsByTagName('img')[0]); | |
})(); |
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 Twitter - add self-retweet class | |
// @namespace https://gist.github.com/am4dr/e403980f0c6788d7979a537923afb1d8 | |
// @version 0.1.2 | |
// @description add `self-retweet` class to self-retweeted tweets | |
// @author am4dr | |
// @updateURL https://gist.github.com/am4dr/e403980f0c6788d7979a537923afb1d8/raw/twitter_self-retweet_class.user.js | |
// @match *://twitter.com/* | |
// @run-at document-end | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function addSelfRetweetClassIfItIs(streamItem) { | |
if (!streamItem) { return; } | |
const tweet = streamItem.getElementsByClassName('tweet')[0]; | |
if (tweet.dataset.screenName === tweet.dataset.retweeter) { | |
tweet.classList.add('self-retweet'); | |
} | |
} | |
const streamOl = document.getElementById('stream-items-id'); | |
const tweets = streamOl.getElementsByClassName('stream-item'); | |
for (const tweet of tweets) { addSelfRetweetClassIfItIs(tweet); } | |
const obs = new MutationObserver(records => | |
records.forEach(r => r.addedNodes.forEach(addSelfRetweetClassIfItIs)) | |
); | |
obs.observe(streamOl, {childList: true}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment