Skip to content

Instantly share code, notes, and snippets.

@koreapyj
Last active January 11, 2024 11:14
Show Gist options
  • Save koreapyj/d1bb06642e79163f7833e05193df4605 to your computer and use it in GitHub Desktop.
Save koreapyj/d1bb06642e79163f7833e05193df4605 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Yahoo Transit
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://transit.yahoo.co.jp/timetable/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=yahoo.co.jp
// @grant none
// ==/UserScript==
(function() {
'use strict';
Array.from(document.querySelectorAll('a[href^="/station/"]')).forEach(x=>{
const li = document.createElement('li')
const a = document.createElement('a')
const url = new URL(x.href)
const {1:station} = url.pathname.match(/^\/station\/(\d+)/)
a.href = `/timetable/${station}`
a.textContent = '時刻表'
li.appendChild(a)
x.parentNode.parentNode.insertBefore(li, x.parentNode)
})
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment