Last active
August 29, 2015 14:10
-
-
Save 3846masa/e757d4d96c91c7725aa0 to your computer and use it in GitHub Desktop.
To skip Ads in Youtube.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"manifest_version": 2, | |
"name": "skipYoutubeAds", | |
"version": "0.0.1", | |
"description": "To skip Ads in Youtube.", | |
"content_scripts": [ | |
{ | |
"matches": ["https://www.youtube.com/watch*","http://www.youtube.com/watch*"], | |
"js": ["skipYoutubeAds.js"], | |
"run_at": "document_start" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var $ = function(selector, parentElement) { | |
return (parentElement || document).querySelector(selector); | |
}; | |
window.addEventListener('load', function(){ | |
setTimeout(function hiddenAds(){ | |
var video = $('video'); | |
if ($('.ad-container')) $('.ad-container').style.display = "none"; | |
var video_id; | |
location.search.substr(1).split('&').forEach(function(query) { | |
if (query.match('^v=')) video_id = query.split('=')[1]; | |
}); | |
if (video.readyState === 4 && video_id !== video.getAttribute('data-youtube-id')) { | |
video.currentTime = video.duration; | |
} | |
setTimeout(hiddenAds, 100); | |
}, 100); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment