Skip to content

Commit 2901cd3

Browse files
committed
v0.6-alpha
1 parent 2857e35 commit 2901cd3

File tree

2 files changed

+48
-39
lines changed

2 files changed

+48
-39
lines changed

manifest.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"name": "unBlob",
3-
"version": "0.5",
4-
"version_name": "0.5-alpha",
5-
"description": "",
2+
"name": "unBlob [ALPHA]",
3+
"version": "0.6",
4+
"version_name": "0.6-alpha",
5+
"description": "Best unblob Tool. Open any audio/video outside of websites! 👌",
66
"icons": {
77
"16": "icons/16.png",
88
"32": "icons/32.png",

website-scripts.js

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ unBlob.createUserInterface = function() {
138138
container.className = 'unblob-container--hidden';
139139

140140
link.className = 'unblob-button'
141-
141+
link.target = '_blank';
142142
link.innerHTML = '<svg viewBox="0 0 24 24"><path d="M18 19H6a1 1 0 01-1-1V6c0-.6.5-1 1-1h5c.6 0 1-.5 1-1s-.5-1-1-1H5a2 2 0 00-2 2v14c0 1.1.9 2 2 2h14a2 2 0 002-2v-6c0-.6-.5-1-1-1s-1 .5-1 1v5c0 .6-.5 1-1 1zM14 4c0 .6.5 1 1 1h2.6l-9.1 9.1a1 1 0 101.4 1.4l9.1-9V9c0 .6.5 1 1 1s1-.5 1-1V4c0-.6-.5-1-1-1h-5a1 1 0 00-1 1z"/></svg>';
143143

144144
container.appendChild(link);
@@ -155,21 +155,25 @@ unBlob.createUserInterface = function() {
155155
------------------------------------------------------------------------------*/
156156

157157

158-
unBlob.resizeUserInterface = function(rect) {
159-
if (unBlob.ui.offsetLeft !== rect.left) {
160-
unBlob.ui.style.left = rect.left + 'px';
161-
}
158+
unBlob.resizeUserInterface = function() {
159+
if (unBlob.active) {
160+
var rect = unBlob.active;
162161

163-
if (unBlob.ui.offsetTop !== rect.top) {
164-
unBlob.ui.style.top = rect.top + 'px';
165-
}
162+
if (unBlob.ui.offsetLeft !== rect.left) {
163+
unBlob.ui.style.left = rect.left + 'px';
164+
}
166165

167-
if (unBlob.ui.offsetWidth !== rect.width) {
168-
unBlob.ui.style.width = rect.width + 'px';
169-
}
166+
if (unBlob.ui.offsetTop !== rect.top) {
167+
unBlob.ui.style.top = rect.top + 'px';
168+
}
170169

171-
if (unBlob.ui.offsetHeight !== rect.height) {
172-
unBlob.ui.style.height = rect.height + 'px';
170+
if (unBlob.ui.offsetWidth !== rect.width) {
171+
unBlob.ui.style.width = rect.width + 'px';
172+
}
173+
174+
if (unBlob.ui.offsetHeight !== rect.height) {
175+
unBlob.ui.style.height = rect.height + 'px';
176+
}
173177
}
174178
};
175179

@@ -187,19 +191,28 @@ unBlob.observe = function() {
187191
data = element.getBoundingClientRect();
188192

189193
element.classList.add('unblob-media');
194+
element.unblob_index = unBlob.rects.length;
190195

191196
unBlob.media.push(element);
192197

193198
unBlob.rects.push({
194199
index: unBlob.rects.length
195200
});
196201

197-
var rect = unBlob.rects[unBlob.rects.length];
202+
element.addEventListener('timeupdate', function() {
203+
var data = this.getBoundingClientRect(),
204+
rect = unBlob.rects[this.unblob_index];
198205

199-
rect.left = data.left;
200-
rect.top = data.top;
201-
rect.width = data.width;
202-
rect.height = data.height;
206+
if (data && this.style.display != 'none') {
207+
208+
rect.left = data.left;
209+
rect.top = data.top;
210+
rect.width = data.width;
211+
rect.height = data.height;
212+
213+
unBlob.resizeUserInterface();
214+
}
215+
});
203216
}
204217
}, 1000);
205218
};
@@ -223,6 +236,8 @@ unBlob.updateRects = function() {
223236
rect.height = data.height;
224237
}
225238
}
239+
240+
unBlob.resizeUserInterface();
226241
};
227242

228243

@@ -231,7 +246,7 @@ unBlob.updateRects = function() {
231246
------------------------------------------------------------------------------*/
232247

233248
unBlob.mouseOver = function() {
234-
var active = false;
249+
unBlob.active = false;
235250

236251
for (var i = 0, l = unBlob.rects.length; i < l; i++) {
237252
var rect = unBlob.rects[i];
@@ -242,16 +257,16 @@ unBlob.mouseOver = function() {
242257
unBlob.mouse.x < rect.left + rect.width &&
243258
unBlob.mouse.y < rect.top + rect.height
244259
) {
245-
active = rect;
260+
unBlob.active = rect;
246261
}
247262
}
248263

249-
if (active) {
250-
if (unBlob.ui) {
264+
if (unBlob.active) {
265+
if (unBlob.ui && unBlob.ui.className !== 'unblob-container') {
251266
unBlob.ui.className = 'unblob-container';
252267
}
253268

254-
var found = unBlob.blobs[unBlob.media[active.index].src];
269+
var found = unBlob.blobs[unBlob.media[unBlob.active.index].src];
255270

256271
if (
257272
found &&
@@ -261,11 +276,11 @@ unBlob.mouseOver = function() {
261276
) {
262277
unBlob.ui_link.href = found.activeSourceBuffers[0].URL.replace(/(\&|\?)range\=[^&]*/, '');
263278
} else {
264-
unBlob.ui_link.href = unBlob.media[active.index].src;
279+
unBlob.ui_link.href = unBlob.media[unBlob.active.index].src;
265280
}
266281

267-
unBlob.resizeUserInterface(active);
268-
} else if (unBlob.ui) {
282+
unBlob.resizeUserInterface();
283+
} else if (unBlob.ui && unBlob.ui.className !== 'unblob-container--hidden') {
269284
unBlob.ui.className = 'unblob-container--hidden';
270285
}
271286
};
@@ -285,20 +300,14 @@ unBlob.init = function() {
285300
unBlob.createUserInterface();
286301
unBlob.observe();
287302

288-
window.addEventListener('scroll', unBlob.updateRects);
289-
window.addEventListener('mousewheel', unBlob.updateRects);
303+
setInterval(unBlob.mouseOver);
290304

291-
window.addEventListener('resize', function() {
292-
setTimeout(function() {
293-
unBlob.updateRects();
294-
}, 100);
295-
});
305+
window.addEventListener('popstate', unBlob.updateRects);
306+
window.addEventListener('scroll', unBlob.updateRects);
296307

297308
window.addEventListener('mousemove', function(event) {
298309
unBlob.mouse.x = event.clientX;
299310
unBlob.mouse.y = event.clientY;
300-
301-
unBlob.mouseOver();
302311
});
303312
});
304313
};

0 commit comments

Comments
 (0)