summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--viewtube.js35
1 files changed, 5 insertions, 30 deletions
diff --git a/viewtube.js b/viewtube.js
index 5ed5a7a..7bf2b3b 100644
--- a/viewtube.js
+++ b/viewtube.js
@@ -122,29 +122,6 @@
return obj;
}
- function getMyElement(obj, type, from, value, child, content) {
- var getObj, chObj, coObj;
- var pObj = (!obj) ? page.doc : obj;
- if (type == 'body') getObj = pObj.body;
- else {
- if (from == 'id') getObj = pObj.getElementById(value);
- else if (from == 'class') getObj = pObj.getElementsByClassName(value);
- else if (from == 'tag') getObj = pObj.getElementsByTagName(type);
- else if (from == 'ns') getObj = pObj.getElementsByTagNameNS(value, type);
- }
- chObj = (child >= 0) ? getObj[child] : getObj;
- if (content && chObj) {
- if (type == 'html' || type == 'body' || type == 'div' || type == 'option') coObj = chObj.innerHTML;
- else if (type == 'object') coObj = chObj.data;
- else if (type == 'img' || type == 'video' || type == 'embed') coObj = chObj.src;
- else coObj = chObj.textContent;
- return coObj;
- }
- else {
- return chObj;
- }
- }
-
function modifyMyElement(obj, type, content, clear, hide) {
if (content) {
if (type == 'div') obj.innerHTML = content;
@@ -431,10 +408,8 @@
var getMethod = (url != page.url) ? 'XHR' : 'DOM';
if (!sources[url]) sources[url] = {};
if (getMethod == 'DOM') {
- if (!sources[url]['DOM']) {
- sources[url]['DOM'] = getMyElement('', 'html', 'tag', '', 0, true);
- if (!sources[url]['DOM']) sources[url]['DOM'] = getMyElement('', 'body', '', '', -1, true);
- }
+ if (!sources[url]['DOM'])
+ sources[url]['DOM'] = document.querySelector("html").innerHTML;
myPageContent = sources[url]['DOM'];
if (clean) myPageContent = cleanMyContent(myPageContent, true);
myVideosParse = myPageContent.match(pattern);
@@ -527,10 +502,10 @@
}
/* Video Availability */
- var ytVideoUnavailable = getMyElement('', 'div', 'id', 'player-unavailable', -1, false);
+ var ytVideoUnavailable = document.querySelector("#player-unavailable");
if (ytVideoUnavailable) {
if (ytVideoUnavailable.className.indexOf('hid') == -1) {
- var ytAgeGateContent = getMyElement('', 'div', 'id', 'watch7-player-age-gate-content', -1, true);
+ var ytAgeGateContent = document.querySelector("#watch7-player-age-gate-content");
if (!ytAgeGateContent) return;
else {
if(ytAgeGateContent.indexOf('feature=private_video') != -1) return;
@@ -567,7 +542,7 @@
/* Player Size */
var ytSidebarMarginNormal = 382;
- var ytSidebarWindow = getMyElement('', 'div', 'id', 'watch7-sidebar', -1, false);
+ var ytSidebarWindow = document.querySelector("#watch7-sidebar");
if (ytSidebarWindow) {
var ytSidebarWindowStyle = ytSidebarWindow.currentStyle || window.getComputedStyle(ytSidebarWindow);
if (ytSidebarWindowStyle) ytSidebarMarginNormal = -12 + parseInt(ytSidebarWindowStyle.marginTop.replace('px', ''));