-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.php
executable file
·105 lines (82 loc) · 3.28 KB
/
parser.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
if ($_GET['quest'] == "" || !isset($_GET['quest']))
$quest = "12969";
else
$quest = $_GET['quest'];
$data = file_get_contents("http://www.wowhead.com/quest=" . $quest);
?>
<style type="text/css">
#content, #zul-bar { display: none; }
body {
background-color: #fff !important;
color: #000 !important;
}
#result { margin-left: 10px; }
</style>
<div id="content">
<?= $data ?>
</div>
<div id="result"></div>
<script>
window.onload = function() {
var parsed = "<b>QuestID:</b> <?= $quest ?> <br>";
var sidebar = document.getElementById("sidebar");
var infobox = sidebar.getElementsByClassName("infobox");
var li = infobox[0].getElementsByTagName("ul")[0].getElementsByTagName("li");
var ProgressText = "", CompletionText ="";
var reqLevel, reqFaction = "none", reqClass = "none";
if (document.getElementById("lknlksndgg-completion") != null) {
CompletionText = document.getElementById("lknlksndgg-completion").innerHTML;
CompletionText = CompletionText.replace(/\<br\>/g, "\n");
CompletionText = CompletionText.replace(/\ \;/g, " ");
CompletionText = CompletionText.replace(/\<\;/g, "<");
CompletionText = CompletionText.replace(/\>\;/g, ">");
}
if (document.getElementById("lknlksndgg-progress") != null) {
ProgressText = document.getElementById("lknlksndgg-progress").innerHTML;
ProgressText = ProgressText.replace(/\<br\>/g, "\n");
ProgressText = ProgressText.replace(/\ \;/g, " ");
ProgressText = ProgressText .replace(/\<\;/g, "<");
ProgressText = ProgressText .replace(/\>\;/g, ">");
}
for (var i = 0; i < li.length; i++) {
if (li[i].innerHTML.indexOf("Requires level") > -1) {
reqLevel = li[i].innerText.replace("Requires level ", "");
}
else if (li[i].innerHTML.indexOf("Side") > -1) {
reqFaction = li[i].innerText.replace("Side: ", "");
}
else if (li[i].innerHTML.indexOf("Class") > -1) {
reqClass = li[i].innerText.replace("Class: ", "");
}
}
parsed += "<b>Required Level:</b> " + reqLevel + "<br>";
parsed += "<b>Faction: </b>" + reqFaction + "<br>";
parsed += "<b>Class: </b>" + reqClass + "<br>";
parsed += "<b>ProgressText: </b>" + ProgressText + "<br>";
parsed += "<b>CompletionText: </b>" + CompletionText + "<br>";
console.log("Required Level: " + reqLevel);
console.log("Faction: " + reqFaction);
console.log("Class: " + reqClass);
console.log("ProgressText: " + ProgressText);
console.log("CompletionText: " + CompletionText);
var NextQuestID = "0", PrevQuestID = "0";
var quests;
if (infobox[1].getElementsByClassName("series")[0] != null) {
quests = infobox[1].getElementsByClassName("series")[0].getElementsByTagName("td");
for (var i = 0; i < quests.length; i++) {
if (quests[i].innerHTML.indexOf("<b>") > -1 && quests[i].innerHTML.indexOf("<a") == -1) {
if(quests[i-1] != null)
PrevQuestID = quests[i-1].getElementsByTagName("a")[0].getAttribute("href").replace("/quest=", "");
if(quests[i+1] != null)
NextQuestID = quests[i+1].getElementsByTagName("a")[0].getAttribute("href").replace("/quest=", "");
}
}
}
console.log("Prev Quest ID: " + PrevQuestID);
console.log("Next Quest ID:" + NextQuestID);
parsed += "<b>Prev Quest ID: </b>" + PrevQuestID + "<br>";
parsed += "<b>Next Quest ID: </b>" + NextQuestID + "<br>";
document.getElementById("result").innerHTML = parsed;
};
</script>