-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontentscript.js
More file actions
118 lines (104 loc) · 3.87 KB
/
Copy pathcontentscript.js
File metadata and controls
118 lines (104 loc) · 3.87 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
function imgError(image) {
image.onerror = "";
var s = chrome.extension.getURL("images/icons/notfound.gif")
image.src = s;
return true;
}
$(document).ready(function() {
var storage = chrome.storage.sync;
var g;
var next;
var settings = [];
chrome.storage.sync.get(settings,function (obj){
g = obj;
//console.log(window.location.href)
var emote = ":([A-Za-z0-9]+):";
var h = new RegExp(emote, 'gi');
var s = chrome.extension.getURL("images/icons/notfound.gif")
$(".userContent").each(function(index, post){ //for the op
console.log("hey")
$this = $(post)
var comment = $this[0].innerText
var h = new RegExp(emote, 'g');
var t;
while ((t = h.exec(comment))!=null){
//console.log(t)
var s = chrome.extension.getURL("images/"+t[1]+".gif")
var saimg = '<img src="'+ s +'" title="'+t[1]+'" class="img" border="0">'
$this[0].innerHTML = $this[0].innerHTML.replace(":"+t[1]+":", saimg)
}
$("img").error(function () {
$(this).unbind("error").attr("src", s);
});
})
$("#contentArea").find(".UFICommentBody").each(function(index, post){ //for the first time page load
$this = $(post)
var comment = $this[0].innerText
var h = new RegExp(emote, 'g');
var t;
while ((t = h.exec(comment))!=null){
//console.log(t)
var s = chrome.extension.getURL("images/"+t[1]+".gif")
var saimg = '<img src="'+ s +'" title="'+t[1]+'" class="img" border="0" >'
$this[0].innerHTML = $this[0].innerHTML.replace(":"+t[1]+":", saimg)
}
$("img").error(function () {
$(this).unbind("error").attr("src", s);
});
})
$(".userContentWrapper").each(function(index, post){ //for the op
console.log("FOUND THE FORM")
// console.log($(this).serialize())
//console.log($(this).find("[name='add_comment_text']").val())
// $(this).find("[name='add_comment_text']").sendkeys("eyyy")
// console.log($(this).find("[name='add_comment_text_text']")[0].innerText = "hey")
// console.log($(this).find("[name='add_comment_text_text']")[0].innerText)
// var event = jQuery.Event('keypress');
// event.which = 13;
// event.keyCode = 13; //keycode to trigger this for simulating enter
// jQuery(this).trigger(event);
console.log($(this).serialize())
console.log($(this).find("input[name='clp']").val())
// $( "form" ).submit(function( event ) {
// alert( "Handler for .submit() called." );
// console.log("hahahaha vag")
// event.preventDefault();
// });
$.ajax({
type: "POST",
url: "/ajax/ufi/modify.php",
data: $(this).serialize() + "&" + $.param({ add_comment_text_text: "test" }) + "&" + $.param({ add_comment_text: "test" }),
success: function(html)
{
console.log(html)
},
error: function(html)
{
console.log(html.responseText)
}
});
});
$(document.body).on('DOMNodeInserted', function(e) { //every time something is inserted
//console.log(e.target)
console.log("Lol")
if ($(e.target).is('.UFIList') || $(e.target).children().is('.UFIComment') || $(e.target).is('.UFIComment') ) {
//console.log("inserted")
$(e.target).find(".UFICommentBody").each(function(index, post){
$this = $(post)
var comment = $this[0].innerText
var h = new RegExp(emote, 'g');
var t;
while ((t = h.exec(comment))!=null){
//console.log(t)
var s = chrome.extension.getURL("images/"+t[1]+".gif")
var saimg = '<img src="'+ s +'" title="'+t[1]+'" class="img" border="0">'
$this[0].innerHTML = $this[0].innerHTML.replace(":"+t[1]+":", saimg)
}
})
}
$("img").error(function () {
$(this).unbind("error").attr("src", s);
});
});
});
});