Skip to content

Instantly share code, notes, and snippets.

@NoxArt
Last active June 30, 2020 21:23
Show Gist options
  • Save NoxArt/2844eef59d5c1457a2faa790c1c6efeb to your computer and use it in GitHub Desktop.
Save NoxArt/2844eef59d5c1457a2faa790c1c6efeb to your computer and use it in GitHub Desktop.
Kancolle Event floating menu
// ==UserScript==
// @name Kancolle Event map switcher
// @namespace http://tampermonkey.net/
// @version 0.1
// @author NoxArt
// @match https://kancolle.fandom.com/wiki/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var $ = window.jQuery;
$(window).load(function() {
var $header = $("#PageHeader h1");
var headerText = $header.text();
if( headerText.indexOf("Event") == -1) {
return;
}
var styles = [];
styles.push(".__floatingBar { width: 90px; position: fixed; top: 300px; left: 50%; margin-left: -705px; background: white; padding: 7px; border-radius: 5px; z-index: 1000; }");
styles.push(".__tabHandle { font-weight: bold; padding: 10px; text-align: center; cursor:pointer; border-radius: 4px; border: 2px solid white; }");
styles.push(".__tabHandle:hover { background: rgb(221, 238, 255); border-color: rgb(0, 108, 176); color: rgb(0, 108, 176); }");
styles.push("@media (max-width: 1602px) { .__floatingBar { margin-left: -620px; } }");
$("<style type='text/css'>").text(styles.join("\n")).prependTo("body");
var tabs = [];
var $sourceTabs = $("#EventTemplate #flytabs_0 .tabs li");
$sourceTabs.each(function() {
var tab = $(this);
tabs.push(tab);
});
var $floatingBar = $("<div class='__floatingBar' />");
var $container = $("#WikiaPage");
$floatingBar.appendTo($container);
for(var i = 0; i < tabs.length; i++) {
var matchingTab = tabs[i];
var title = matchingTab.text();
var $mapHandle = $("<div class='__tabHandle' />").text(title);
$mapHandle.appendTo($floatingBar);
$mapHandle.data('tab', matchingTab);
$mapHandle.click(function() {
$(this).data('tab').find("a").click();
});
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment