// ==UserScript== // @name 巴哈SauceNAO圖搜按鈕 // @description 巴哈姆特SauceNAO圖搜按鈕 // @author mogeko12345 // @version 1.0.1 // @namespace https://home.gamer.com.tw/Mogeko12345 // @match https://forum.gamer.com.tw/C.php* // @grant none // @downloadURL none // ==/UserScript== (function(){ function search(){ var article = document.getElementsByClassName("c-article FM-P2")[this.value]; var img = article.getElementsByClassName("photoswipe-image"); if(img.length === 0){ img = article.getElementsByClassName("loadpic photoswipe-image-shrink"); } for(var ii = 0; ii < img.length; ii++){ window.open("http://saucenao.com/search.php?db=999&url=" + img[ii].href, "_blank"); } } var header = document.getElementsByClassName("c-post__header__tools"); for(var i = 0; i < header.length; i++){ var button = document.createElement("button"); var inner = document.createElement("i"); inner.className = "icon-font"; inner.appendChild(document.createTextNode("搜")); button.className = "ef-btn"; button.value = i; button.addEventListener("click", search, false); button.appendChild(inner); header[i].appendChild(button); } })();