-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patha.js
More file actions
280 lines (254 loc) · 11.8 KB
/
a.js
File metadata and controls
280 lines (254 loc) · 11.8 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
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
// $("img, script, body").attr("onload", "window.open = function(url){fetch(url); return window;}");
let href;
let watchOverlay;
let time;
let box = $('.verticalDynamic>.mbox.egybetter');
if (!box.length && (box = $('.verticalDynamic>.mbox')))
box.before(box = box.clone().addClass('egybetter'));
box.find('.bdb>strong').text('EgyBetter').attr('class', 'green');
box.find('.pda:not(.bdb)>strong')
.removeClass('red')
.css({ 'text-align': 'right', display: 'block' })
.html(`
● الإضافة متوفرة الآن على
<a href="https://addons.mozilla.org/firefox/addon/egybetter/" target="_blank">فايرفوكس</a>
!
<br>
● للإخبار عن المشاكل أو الاقتراحات والتعرف على الأخبار المتعلقة بالاضافة زورو
<a href="https://www.facebook.com/egybetter.support/" target="_blank">
صفحة الفيسبوك الخاصة بـEgybetter
</a>
`);
fetch(browser.extension.getURL('annoucements.html'))
.then(t => t.text())
.then(html => $('body').prepend(html));
document.onkeydown = e => { e.code == "Escape" && $('.i-min.egybetter')[0].click(); };
const f = async function (adblock = 1) {
if (adblock && href == location.href) return;
href = location.href;
!/\/(movie|episode)\//g.test(location.href) &&
watchOverlay && watchOverlay.hide().find('iframe').attr('src', 'about:blank');
if (/\/(movie|episode)\//g.test(location.href)) {
$('#watch_dl').attr('id', '__watch_dl');
if (adblock && !$('#watch_dl').length) {
$('#mainLoad>.msg_box.full').addClass('__egbSafe').text('سيتم استرجاع الفيديو..');
fetch(location.href).then(t => t.text())
.then(t => {
if (!$('#watch_dl, #__watch_dl').length)
$('#mainLoad>.msg_box.full').replaceWith($(t).find('#watch_dl'))
$('#watch_dl').attr('id', '__watch_dl');
f(0);
});
return;
}
$('.full_movie.table.full.mgb').after($('#__watch_dl'));
let act;
$('.dls_table').before(act = $('<strong/>', {
class: 'msg_box notice i i-info activation egybetter',
css: { float: 'left', width: '50%', 'text-align': 'center' },
text: 'جاري التحميل..'
}));
const dl = g();
dl.grabAll().finally(_ => act.text('انتهى') && setTimeout(() => act.fadeOut(), 2e3));
const currentSelector = `a.movie[href*='${location.pathname}']`;
const currentEp = $(currentSelector);
const nextEp = $(currentSelector).prev();
const prevEp = $(currentSelector).next();
if (!watchOverlay) {
watchOverlay = $(await fetch(browser.extension.getURL('overlay.html')).then(t => t.text()));
watchOverlay.find('.next, .prev').on('click', e => watchOverlay.find('.bdb strong').text('بلاتي شوية..'));
watchOverlay.find('img').attr('src', browser.extension.getURL('icon.png'));
// watchOverlay.find('.i-close').on('click', _=>{
// if(confirm(''))
// })
$('body').prepend(watchOverlay);
}
$('#download').replaceWith($('<a/>', {
href: '#', html: '<strong>أنقر للمشاهدة بطريقة EgyBetter!</strong>',
class: 'mbox msg_box green egybetter_player', css: { 'text-align': 'center' }
}).on('click', e => {
e.preventDefault();
localStorage.setItem('egybetter_player', 1);
watchOverlay.css('display', 'flex') && $('.egybetter_player').hide();
watchOverlay.css('top', 0);
}));
if (localStorage.getItem('egybetter_player')) $('.egybetter_player')[0].click();
watchOverlay.find('.bdb>strong').text($('.movie_title>h1').eq(0).text());
watchOverlay.find('iframe').attr('src', $(`#__watch_dl iframe`).attr('src'));
watchOverlay.find('.next').css('visibility', nextEp.length ? '' : 'hidden')
.text(nextEp.find('.title').text())
.attr('href', nextEp.attr('href'));
watchOverlay.find('.prev').css('visibility', prevEp.length ? '' : 'hidden')
.text(prevEp.find('.title').text())
.attr('href', prevEp.attr('href'));
if (localStorage.getItem('hide_egyb_player'))
watchOverlay.find('.i-lock.egybetter').addClass('i-unlock error') &&
watchOverlay.find('.i-min.egybetter')[0].click();
else
watchOverlay.css('top', 0);
top.nextEpisode = _ => {
if (nextEp.length) setTimeout(_ => watchOverlay.find('.next')[0].click(), 10);
return nextEp.length;
}
top.prevEpisode = _ => {
if (prevEp.length) setTimeout(_ => watchOverlay.find('.prev')[0].click(), 10);
return prevEp.length;
}
top.onmessage = e => e.data.func.includes('Episode_egyb') &&
e.source.postMessage({
result: top[e.data.func.replace('_egyb', '')](),
token: e.data.token
}, e.origin);
}
else if (location.href.includes("/season/")) {
const eps = $(".movies_small:not(.contents) .movie");
if (!eps.length) return href = null;
fetch(browser.extension.getURL('idm_tuto.html')).then(t => t.text()).then(html => {
html = html.replace('////', browser.extension.getURL(''));
$('body').prepend(html);
});
const serieName = $('td.movie_title').parent().next().find('a').text();
const imgURL = 'https://i.ya-webdesign.com/images/gif-loading-png-1.gif';
const loader = $('<img/>', { src: imgURL, css: { width: 20, display: 'block', margin: '0 auto' } });
const checker = loader.clone().attr('src', 'https://www.elfarsalicar.com/en/public/img/check.gif');
const data = { num: {}, missed: {}, size: {}, downloads: {} };
const table = $('<table/>', { class: 'dls_table btns full mgb egybetter' });
table.append(`
<thead>
<tr>
<th></th><th>الدقة</th><th>الحجم</th>
<th>
<a class='i i-help green' style='cursor:help;'
onmousemove="$('.egybetter.idm_tuto').show()"
onmouseout="$('.egybetter.idm_tuto').hide()">حمل باستخدام IDM</a>
أو انقر على
<i class='i i-dl blue'></i>
للتحميل على المتصفح
</th>
</tr>
</thead>
`);
table.append(`<tbody></tbody>`);
table.find('th').eq(0).width('9%').append(loader.clone());
table.find('th').eq(1).width('17%');
table.find('th').eq(2).width('14%');
const tbody = table.find('tbody');
$("#mainLoad .mbox[class='mbox']").eq(0).before([
$('<center/>', {
class: 'msg_box notice egybetter',
html: '<strong><div>جاري الغلغلة.. </div><div class="activation egybetter"></div></strong>',
css: { margin: 0, 'border-radius': 0 }
}),
table,
$('<center/>', {
class: 'msg_box warn كلاخء',
html: `<strong>يمكنك تسريع العملية من هنا
<input type='checkbox' class='egybetter speedup'
onclick="localStorage.setItem('egyb_speedup', this.checked ? '1':'')"
${localStorage.getItem('egyb_speedup') ? 'checked' : ''}>
(قد لا تعمل)
</strong>
`
})
]);
const notice = $('.msg_box.egybetter').find('div').eq(0);
let c = 0;
setTimeout(() => {
if (!c && c < eps.length)
notice.text('من الأسباب التي تؤخر هذه العملية vidstream لأنه يتطلب تغعيلا بين الحين والآخر، كما قد يكون السبب الأنترنيت الضعيفة أو مشكل بالموقع');
}, 2e4);
for (let i = eps.length - 1; i >= 0; i--) {
const el = eps[i];
const prom = g(el.href).grabAll().then(d => {
const title = $(el).find('.title').text().trim();
notice.text(`تم قصف ${title}`);
for (const k in d.apiUrls) {
const cls = k.replace(/[ ."'<]/g, '_').toLowerCase();
if (!tbody.find('.' + cls).length) {
data.downloads[k] = eps.toArray().map(el => '___' + $(el).children('.title').text().trim());
data.size[k] = 0;
data.num[k] = 0;
data.missed[k] = data.missed[k] || 0;
tbody.append(`<tr class="${cls}">${('<td>' + k + '</td>').repeat(4)}</tr>`);
};
if (!d.downloads[k]) {
notice.text(`تبا، الجودة ${k} فشلت (${title})`);
data.missed[k]++;
continue;
}
const tds = tbody.find('.' + cls + '>td');
tds.eq(2).text(u.convertSize((data.size[k] += parseFloat(d.info[k].size)) + 'MB', undefined, 2));
data.downloads[k][i] = d.downloads[k];
}
}).catch(_ => {
["Full HD 1080p", "HD 720p", "SD 480p", "SD 360p", "Low 240p"]
.forEach(k => data.missed[k] ? data.missed[k]++ : (data.missed[k] = 1));
notice.text(`تبا، فشلت العملية في ${$(el).find('.title').text().trim()}`);
}).finally(_ => {
for (const k in data.num) {
const cls = k.replace(/[ ."'<]/g, '_').toLowerCase();
const tds = tbody.find('.' + cls + '>td');
const missing = data.missed[k] ? `<span style='color:red'>(${data.missed[k]}-)</span> ` : '';
tds.eq(0).html(`${missing} ${++data.num[k]}/${eps.length}`);
tds.eq(3).html(
$(`<textarea>${data.downloads[k].join('\n')}</textarea>`, { readonly: true })
.on('mouseup', e => e.target.select())
);
if (c + 1 == eps.length)
tds.eq(3).append(
$('<a/>', { class: 'i i-dl egybetter', href: '#', css: { 'margin-right': '20px' }, title: 'التحميل عبر المتصفح' })
.on('click', e => {
e.preventDefault();
const l = loader.clone().css({ margin: '0 30px', width: '45px', display: 'inline-block' });
$(e.currentTarget).hide().after(l);
const text = notice.text();
notice.text('سيتم بدء التحميل بعد قليل..');
const filename = l.next()[0].checked ? serieName : undefined;
browser.runtime.sendMessage(
{ downloads: data.downloads[k], filename: filename },
_ => notice.text(text) && l.remove() && $(e.currentTarget).show()
);
})
)
.append($('<input/>', {
'data-q': k, type: 'checkbox',
checked: Boolean(JSON.parse(localStorage.createSeriesFolder || '{}')[k])
}).on('click', e => {
const el = e.currentTarget;
let chck = {};
$(el).parents('table').find('input[type=checkbox]')
.each((_, elm) => chck[$(elm).data('q')] = elm.checked ? '1' : '');
localStorage.createSeriesFolder = JSON.stringify(chck);
}))
.append(`<span style="width: max-content;">إنشاء مجلد بإسم المسلسل</span>`);
}
if (++c == eps.length) {
table.find('th').eq(0).empty().append(checker);
notice.text('بالصحة والراحة!');
$('.activation.egybetter').empty();
}
});
if (!(i % 2) && !$('.egybetter.speedup')[0].checked)
await prom;
}
} else if (location.href.includes('/series/'))
href = $('#mainLoad .mbox').eq(1).before([
$('<strong/>', { class: 'mbox msg_box notice tam', text: 'للتحميل اختر أحد المواسم' }),
$($('.contents').parents('.mbox').toArray().reverse())
]).length ? location.href : null;
}
f();
$('body').on('DOMSubtreeModified', f);
$('#head>.table').append(`
<div class="td vam" align="center">
<input class="egyb_switch" type="checkbox" id="egyb_switch"
${localStorage.getItem('darkmode') ? 'checked' : ''}
onclick="
$('#egyb__darkmode_switcher').toggleClass('egyb__darkmode');
localStorage.setItem('darkmode', this.checked ? '1' : '');
">
<label type="checkbox" for="egyb_switch" title="Dark mode">
<div class="i i-moon"></div>
</label>
</div>
`);