Ghost Trappers - Loot Alerter

To be used with the Ghost Trappers Facebook game. This script will alert you when you received the loot you specify

目前為 2015-10-18 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Ghost Trappers - Loot Alerter
// @author       Rani Kheir
// @version      2.0
// @description  To be used with the Ghost Trappers Facebook game. This script will alert you when you received the loot you specify
// @include      *ghost-trappers.com*
// @icon         http://i44.photobucket.com/albums/f36/Rani-Kheir/ghosticon_zpsc395e1ce.png
// @copyright    2015+, Rani Kheir
// @namespace https://greasyfork.org/users/4271
// ==/UserScript==

if(typeof(Storage) !== "undefined") {
    if (!localStorage.gTLootNotifier) {localStorage.gTLootNotifier = "ThisShallNotExistByDefault.Ever.";}
    if (!localStorage.gTLootNotifierBool) {localStorage.gTLootNotifierBool = false;}
} else {
    var node = document.createElement("P");
    var textnode = document.createTextNode("Browser doesn't support Local Storage - Sorry!");
    node.appendChild(textnode);
    document.getElementsByClassName("rightBanners")[0].appendChild(node);
}

var node0= document.createElement("P");
var textnode0 = document.createTextNode("GT Loot Watcher");
node0.appendChild(textnode0);

var node1 = document.createElement("P");
var textnode1 = document.createTextNode("Watch for:");
node1.appendChild(textnode1);

var node2 = document.createElement("INPUT");
node2.setAttribute("id", "id_you_like");


var node3 = document.createElement("BUTTON");
var textnode2 = document.createTextNode("Save");
node3.appendChild(textnode2);


document.getElementsByClassName("rightBanners")[0].appendChild(node0);
document.getElementsByClassName("rightBanners")[0].appendChild(node1);
document.getElementsByClassName("rightBanners")[0].appendChild(node2);
document.getElementsByClassName("rightBanners")[0].appendChild(document.createElement("BR"));
document.getElementsByClassName("rightBanners")[0].appendChild(document.createElement("BR"));
document.getElementsByClassName("rightBanners")[0].appendChild(node3);

node3.onclick=function(){
    var test = document.getElementById("id_you_like").value;    
    localStorage.gTLootNotifier = test;
    //alert(test); - worked
    //alert(localStorage.gTLootNotifier); - worked!
    
    localStorage.gTLootNotifierBool = true;
};


var node4 = document.createElement("BUTTON");
var textnode3 = document.createTextNode("Cancel");
node4.appendChild(textnode3);

document.getElementsByClassName("rightBanners")[0].appendChild(node4);

node4.onclick=function(){
    localStorage.gTLootNotifierBool = false;
};

if (localStorage.gTLootNotifierBool === "true") {
    var obtainFirstLog = document.getElementsByClassName('logText')[0].innerHTML;
    var searchForThis = localStorage.gTLootNotifier;
    var myLovelyRegex = new RegExp(searchForThis, 'gi');
    if (obtainFirstLog.match(myLovelyRegex))
        { alert("Congratulations!\n\nYou have obtained: " + searchForThis); }
}



// Styling
node0.style.color = "white";
node0.style.fontSize = "14px";
node0.style.fontFamily = "Calibri";
node0.style.paddingTop = "3px";
node0.style.paddingBottom = "8px";
node0.style.margin = "0px";

node1.style.color = "white";
node1.style.fontSize = "11px";
node1.style.fontFamily = "Calibri";
node1.style.padding = "0px";
node1.style.margin = "0px";

node2.placeholder = "Type Loot Name Here";
node2.style.fontFamily = "Consolas";

node3.style.fontSize = "11px";
node3.style.fontFamily = "Calibri";
node3.style.width = "48%";

node4.style.fontSize = "11px";
node4.style.fontFamily = "Calibri";
node4.style.width = "48%";
node4.style.marginLeft = "3px";