-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
69 lines (59 loc) · 1.89 KB
/
app.js
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
$(document).ready(function() {
var data =
[
{
"keywords": [
"voucher",
"print",
"sis"
],
"link": "https://www.facebook.com/groups/877212202301031/permalink/877283145627270/"
},
{
"keywords": [
"music",
"registration",
"organizer"
],
"link": "https://www.facebook.com/groups/877212202301031/permalink/877322645623320/"
},
{
"keywords": [
"overload",
"requirements",
"certification"
],
"link": "https://www.facebook.com/groups/877212202301031/permalink/877282138960704/"
}
]
$(document).ready(function() {
$("li").find('button:contains("Post")')
.parent().append("<button id='check' class='_42ft _4jy0 _11b _4jy3 _4jy1'>Look for Answer</button>");
$("#u_0_2").append("<li class='groupsCleanLinkBorder'><a href='#' class='groupsCleanLink'>Filter Post</a></li>");
function check(content) {
var regex;
for (var post in data) {
for (var keyword in data[post].keywords) {
regex = new RegExp(data[post].keywords[keyword], "gi");
if (content.match(regex)) {
return data[post].link;
}
}
}
return false;
}
document.getElementById("check").addEventListener("click", function(e) {
e.preventDefault();
var url = check($("textarea[placeholder='Write something...']").val());
if (url) {
if (window.prompt("Eto yung sagot, di ka kasi nagbabase e: ", url)) {
var win = window.open(url, "_blank");
win.focus();
}
} else {
alert("Ge, magtanong na ka");
}
}, false);
console.log("Done Loading");
});
});