-
Notifications
You must be signed in to change notification settings - Fork 1
/
PornhubBroswerUpload.js
110 lines (98 loc) · 3.54 KB
/
PornhubBroswerUpload.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
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
//simulate start
function simulate(element, eventName)
{
//http://stackoverflow.com/questions/6157929/how-to-simulate-a-mouse-click-using-javascript
//How to use:
//simulate(document.getElementById("btn"), "click");
//OR
//simulate(document.getElementById("btn"), "click", { pointerX: 123, pointerY: 321 });
var options = extend(defaultOptions, arguments[2] || {});
var oEvent, eventType = null;
for (var name in eventMatchers)
{
if (eventMatchers[name].test(eventName)) { eventType = name; break; }
}
if (!eventType)
throw new SyntaxError('Only HTMLEvents and MouseEvents interfaces are supported');
if (document.createEvent)
{
oEvent = document.createEvent(eventType);
if (eventType == 'HTMLEvents')
{
oEvent.initEvent(eventName, options.bubbles, options.cancelable);
}
else
{
oEvent.initMouseEvent(eventName, options.bubbles, options.cancelable, document.defaultView,
options.button, options.pointerX, options.pointerY, options.pointerX, options.pointerY,
options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.button, element);
}
element.dispatchEvent(oEvent);
}
else
{
options.clientX = options.pointerX;
options.clientY = options.pointerY;
var evt = document.createEventObject();
oEvent = extend(evt, options);
element.fireEvent('on' + eventName, oEvent);
}
return element;
}
function extend(destination, source) {
for (var property in source)
destination[property] = source[property];
return destination;
}
var eventMatchers = {
'HTMLEvents': /^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,
'MouseEvents': /^(?:click|dblclick|mouse(?:down|up|over|move|out))$/
}
var defaultOptions = {
pointerX: 0,
pointerY: 0,
button: 0,
ctrlKey: false,
altKey: false,
shiftKey: false,
metaKey: false,
bubbles: true,
cancelable: true
}
//simlate end
//getCount start
window.getCount = function(parent){
//http://stackoverflow.com/questions/12237529/count-how-many-elements-in-a-div
//How to use:
//getCount(document.getElementById('masterTemplate'));
var relevantChildren = 0;
var children = parent.childNodes.length;
for(var i=0; i < children; i++){
if(parent.childNodes[i].nodeType != 3){
relevantChildren++;
}
}
return relevantChildren;
}
//getCount end
//get the total number of video
var totalVideoNumber = getCount(document.getElementById('masterTemplate'));
setTimeout(function() {
for (var i=0;i<totalVideoNumber;i++)
{
uploadid = document.getElementById("template-upload_"+i);
//filename
fileName = uploadid.getElementsByClassName("fileName")[0].innerHTML;
uploadid.getElementsByClassName("uploadInputTitle titleTmplField instField")[0].value = fileName;
//Privacy Settings
document.getElementById('dropDownTitle_1_'+i).innerHTML = "Private";
//Choose a Production
document.getElementById('dropDownTitle_2_'+i).innerHTML = "Homemade";
//Category click
simulate(document.getElementById("categoryId_93_"+i), "click");//feet
simulate(document.getElementById("categoryId_18_"+i), "click");//fetish
simulate(document.getElementById("categoryId_37_"+i), "click");//teen
//Save button
simulate(document.getElementById("uploaderSaveButton_"+i), "click");
}
}, 1000);