Created
September 4, 2022 01:08
-
-
Save fbbp/e6cb08881c2168a6e1e664e1da691a12 to your computer and use it in GitHub Desktop.
dアニメストアの視聴リンクを新しいタブで開くユーザースクリプト
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 Open docomo anime store watch link in pop-up as tab | |
// @namespace https://github.com/fbbp | |
// @version 0.1 | |
// @description dアニメストアの視聴リンクを新しいタブで開く | |
// @author fbbp | |
// @grant GM_openInTab | |
// @match *://animestore.docomo.ne.jp/animestore/ci_pc* | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
unsafeWindow.open = function() {}; | |
function openNewTab(event){ | |
const elements = document.querySelectorAll('a'); | |
for (let i=0; i<elements.length; i++) { | |
if (event.target.parentElement.id === 'streamingQuality' && elements[i].parentElement.id === 'streamingQuality' && elements[i].href.match(/javascript\:void\(0\);$/)) { | |
event.preventDefault(); | |
const matchPath = window.location.href.match(/partId=(\d+)$/);; | |
GM_openInTab('https://animestore.docomo.ne.jp/animestore/sc_d_pc?partId='+matchPath[1] , {active: true}); | |
} | |
} | |
} | |
addEventListener('click', openNewTab, true) | |
} | |
)(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment