diff options
author | Arun Isaac | 2017-07-05 17:36:23 +0530 |
---|---|---|
committer | Arun Isaac | 2017-07-05 18:07:01 +0530 |
commit | 26f2f740b4f15e2114b30b08bb4648bd20794e82 (patch) | |
tree | 593484ce3c385f74d716593ab7e42ea4d2d79afd | |
parent | 2d797c6b7d48763d481f72b3a7b8788b35ee6127 (diff) | |
download | youtube-noscript-shim-26f2f740b4f15e2114b30b08bb4648bd20794e82.tar.gz youtube-noscript-shim-26f2f740b4f15e2114b30b08bb4648bd20794e82.tar.lz youtube-noscript-shim-26f2f740b4f15e2114b30b08bb4648bd20794e82.zip |
Remove `getMyElement'.
* viewtube.js (getMyElement): Remove function.
Replace invocations of `getMyElement' with `document.querySelector'.
-rw-r--r-- | viewtube.js | 35 |
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', '')); |