Wakfu link

Add useful link to wakfu elements, wakfu wiki, and encyclopedia

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name        Wakfu link
// @namespace   eight04.blogspot.com
// @description Add useful link to wakfu elements, wakfu wiki, and encyclopedia
// @include     http://wakfu-elements.com/items/view/*
// @include     http://www.wakfu.com/en/mmorpg/game-guide/*
// @include		http://www.wakfu.asia/en/mmorpg/game/*
// @include     http://wakfu.wikia.com/wiki/*
// @version     1.1.1
// @grant       GM_addStyle
// ==/UserScript==

"use strict";

GM_addStyle(".wakfu-links { font-size: 0.7em; margin: 3px; }" +
	"#infos_detail .wakfu-links { font-size: 14px!important; }");

init();
document.addEventListener("DOMNodeInserted", init, false);

function init(){
	if(document.querySelector(".wakfu-links-container")){
		return;
	}
	var title = getTitle();
	var links = makeLinks(title);
	var header = getHeader();

	header.insertBefore(links, header.childNodes[0].nextSibling)
}
	
function getTitle(){
	var t = getHeader().childNodes[0].textContent;
	return t;
}

function getHeader(){
	var h = document.querySelector("#WikiaPageHeader > h1") ||
			document.querySelector("#infos_detail > .title_item > h2") ||
			document.querySelector("#l-mainBody > .itemWrapper > h3");
	return h;
}

function makeLinks(t){
	var sites = [
		{
			name: "Encyclopedia",
			url: "http://www.wakfu.asia/en/mmorpg/game/search?text="
		},
		{
			name: "Wiki",
			url: "http://wakfu.wikia.com/wiki/"
		},
		{
			name: "Elements",
			url: "http://wakfu-elements.com/search?search="
		}
	]
	
	var d = document.createElement("span");
	d.className = "wakfu-links-container";
	var i;
	
	for(i = 0; i < sites.length; i++){
		var a = document.createElement("a");
		a.textContent = sites[i].name;
		a.setAttribute("href", sites[i].url + t);
		a.className = "wakfu-links";
		a.onclick = function(){
			location.href = this.href;
			return false;
		}
		d.appendChild(a);
	}
	
	return d;
}