Skip to content

Instantly share code, notes, and snippets.

@3846masa
Last active August 29, 2015 14:10
Show Gist options
  • Save 3846masa/e757d4d96c91c7725aa0 to your computer and use it in GitHub Desktop.
Save 3846masa/e757d4d96c91c7725aa0 to your computer and use it in GitHub Desktop.
To skip Ads in Youtube.
{
"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"
}
]
}
(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