Skip to content

Instantly share code, notes, and snippets.

@kphrx
Last active March 23, 2022 17:27
Show Gist options
  • Save kphrx/fb4f21c1bbfa6bcbb484c74824866e65 to your computer and use it in GitHub Desktop.
Save kphrx/fb4f21c1bbfa6bcbb484c74824866e65 to your computer and use it in GitHub Desktop.
Install from raw
// ==UserScript==
// @name Set scroll position to game of KanColle
// @namespace https://gist.github.com/kPherox
// @version 1.1.1
// @description Jump to game frame top of KanColle.
// @author kPherox <[email protected]>
// @match http://www.dmm.com/netgame/social/-/gadgets/=/app_id=854854*
// @run-at document-end
// @grant GM_addStyle
// @updateURL https://gist.github.com/kphrx/fb4f21c1bbfa6bcbb484c74824866e65/raw/jump-to-game-of-kancolle.user.js
// @downloadURL https://gist.github.com/kphrx/fb4f21c1bbfa6bcbb484c74824866e65/raw/jump-to-game-of-kancolle.user.js
// ==/UserScript==
GM_addStyle(`.none-deco {
text-decoration: none !important;
font-weight: bold !important;
color: #fff !important;
}`);
history.scrollRestoration = 'manual';
window.addEventListener("load", function() {
window.scrollTo({ top: 75 })
const p = HTMLElement.prototype;
p.classAdd = function(cls) {
this.classList.add(cls);
return this;
};
p.prependChild = function(elm) {
this.insertBefore(elm, this.firstElementChild);
return elm;
};
const jumpButton = document.createElement('li')
.classAdd('menu-item')
.appendChild(document.createElement('a')
.classAdd('menu')
.classAdd('none-deco'));
jumpButton.href = "#jumpToGame"
jumpButton.textContent = 'Jump To Game';
jumpButton.addEventListener("click", (e) => {
e.preventDefault();
window.scrollTo({ top: 75 });;
});
document.querySelector('.dmm-ntgnavi > .inner.clearfix > .ntgnavi-right > .ntgnavi-item > .menu-list').prependChild(jumpButton.parentNode);;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment