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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
function loadNextPage()
{
chrome.extension.sendRequest({"action": "nextTitleUrl"}, function(nextUrl) {
window.location = nextUrl;
});
}
function skipMovie()
{
chrome.extension.sendRequest(
{
"action": "unknownMovie",
"url": window.location.href
});
loadNextPage();
}
function setClicked(div, clickedByUser)
{
div.style.backgroundColor = 'lightgreen';
div.isClicked = true;
if (clickedByUser && ++quotesSubmitted == 1) {
infobox.removeChild(skipButton);
infobox.removeChild(spacer);
}
}
document.addEventListener('keypress', function(e) {
var element = e.target;
if (element.nodeType == 3)
element = element.parentNode;
if (element.tagName == 'INPUT' || element.tagName == 'TEXTAREA')
return;
if (e.charCode == 115 /* s */)
skipMovie();
else if (e.charCode == 110 /* n */)
loadNextPage();
});
//Remove advertisement:
var advertisement = document.getElementById("tn15adrhs");
if (advertisement != null)
advertisement.parentNode.removeChild(advertisement);
var infobox = document.createElement('div');
var title = document.createElement('strong');
title.innerText = "AnyClip Moment Selector";
var skipButton = document.createElement('strong');
skipButton.style.float = 'right';
skipButton.innerText = "Never Seen/Don't Know It";
skipButton.style.cursor = 'pointer';
skipButton.style.color = '#F78181';
skipButton.style.textDecoration = 'underline';
skipButton.addEventListener('click', skipMovie);
skipButton.title = "keyboard shortcut: s";
var nextButton = document.createElement('strong');
nextButton.style.float = 'right';
nextButton.innerText = "Finished Selecting, Next Movie";
nextButton.style.cursor = 'pointer';
nextButton.style.color = '#F78181';
nextButton.style.textDecoration = 'underline';
nextButton.addEventListener('click', loadNextPage);
nextButton.title = "keyboard shortcut: n";
var levelSelect = document.createElement('select');
levelSelect.style.float = 'right'
var novice = document.createElement('option');
novice.text = "Level 1: Novice";
var movieLover = document.createElement('option');
movieLover.text = "Level 2: Movie Lover";
var totalGeek = document.createElement('option');
totalGeek.text = "Level 3: Total Geek";
levelSelect.add(novice, null);
levelSelect.add(movieLover, null);
levelSelect.add(totalGeek, null);
chrome.extension.sendRequest({'action': 'getLevel'}, function(level) {
levelSelect.selectedIndex = level - 1;
});
levelSelect.addEventListener('change', function() {
chrome.extension.sendRequest(
{
'action' : 'setLevel',
'level': levelSelect.selectedIndex + 1
}, loadNextPage);
var loading = document.createElement('option');
loading.text = "Loading new level...";
levelSelect.add(loading);
levelSelect.selectedIndex = 3;
levelSelect.disabled = true;
});
var spacer = document.createElement('div');
spacer.style.float = 'right';
spacer.innerHTML = " ";
infobox.appendChild(title);
infobox.appendChild(skipButton);
infobox.appendChild(spacer);
infobox.appendChild(nextButton);
infobox.appendChild(spacer.cloneNode(true));
infobox.appendChild(levelSelect);
infobox.style.background = '#36b';
infobox.style.borderBottom = '1px dotted white';
infobox.style.color = '#fff';
infobox.style.padding = '10px';
infobox.style.position = 'relative';
infobox.style.zIndex = '123456';
infobox.style.font = '13px Arial';
document.body.insertBefore(infobox, document.body.firstChild);
var divRegEx = /^qt[0-9]{7}$/;
var divs = document.getElementsByTagName('div');
var quotesSubmitted = 0;
for (var i = 0; i < divs.length; i++) {
if (divRegEx.test(divs[i].id)) {
divs[i].isClicked = false;
divs[i].addMomentLink = document.createElement('div');
divs[i].addMomentLink.style.position = 'relative';
divs[i].addMomentLink.style.top = '-' + divs[i].offsetHeight.toString() + 'px';
divs[i].addMomentLink.style.backgroundColor = '#FE9A2E';
divs[i].addMomentLink.style.width = divs[i].offsetWidth + "px";
divs[i].addMomentLink.style.height = divs[i].offsetHeight + "px";
divs[i].addMomentLink.style.visibility = 'hidden';
divs[i].addMomentLink.style.opacity = '.66';
divs[i].addMomentLink.style.cursor = 'pointer';
var txt = document.createElement('h3');
txt.innerText = "Add this quote as an AnyClip moment";
txt.align = "center";
txt.style.height = divs[i].addMomentLink.style.height;
txt.style.position = 'relative';
txt.style.top = '10px';
txt.style.opacity = '1';
divs[i].addMomentLink.appendChild(txt);
var oldHeight = divs[i].offsetHeight;
divs[i].appendChild(divs[i].addMomentLink);
divs[i].style.height = oldHeight + "px";
divs[i].addEventListener('mouseover', function() {
if (!this.isClicked)
this.addMomentLink.style.visibility = 'visible';
}, false);
divs[i].addEventListener('mouseout', function() {
this.addMomentLink.style.visibility = 'hidden';
}, false);
divs[i].addEventListener('click', function() {
if (!this.isClicked) {
var momentName = prompt("How should I name this moment?\n\nRemember that the moment name will become a part of the URL on AnyClip, so:\n\n1. Name it with words you think people would use when they search for it.\n\n2. Also consider it will be seen internally in a list of results, so make sure it's specific to the moment and helps people select the right moment.\n\n3. Try (not a must) to keep the name to under 6 words\n\n4. Don't use the movie name in the title\n\n5. Be unique (per movie)!", "");
if (momentName != null && momentName != "") {
this.addMomentLink.style.visibility = 'hidden';
this.style.backgroundColor = 'gold';
this.isClicked = true;
var me = this;
chrome.extension.sendRequest(
{
'action' : 'submitMoment',
'url': window.location.href,
'momentName': momentName,
'quote': this.innerText.replace("\nShare this quote", "").replace(/^\s\s*/, '').replace(/\s\s*$/, ''),
'quoteID': me.id
}, function(success) {
if (success)
setClicked(me, true);
else {
me.style.backgroundColor = 'darksalmon';
setTimeout(function() {
me.style.backgroundColor = '';
me.isClicked = false;
},
2000);
}
});
}
}
}, false);
}
}
chrome.extension.sendRequest(
{
'action': 'getAlreadySubmitted',
'url': window.location.href
}, function(list) {
for (var i = 0; i < list.length; i++) {
var div = document.getElementById(list[i]);
if (div != null)
setClicked(div, false);
}
});
|