-
-
Save MeoMix/37b4dbdbb3bd48f3c9e2 to your computer and use it in GitHub Desktop.
YouTube IFrame Inject source
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title> | |
YouTube Test | |
</title> | |
<script type="text/javascript" src="background.js"></script> | |
</head> | |
<body> | |
<div id="YouTubeIFrameTarget"></div> | |
</body> | |
</html> |
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
// When the YouTube API is ready, transform the <div> target into a | |
// YouTube IFrame. This will cause youTubeIFrameInject.cs to be injected into the iframe. | |
window.onYouTubePlayerAPIReady = function() { | |
new window.YT.Player('YouTubeIFrameTarget', { | |
width: 480, | |
height: 360, | |
events: { | |
'onReady': function () { | |
console.log("YouTube IFrameTarget is ready."); | |
}, | |
'onError': function (error) { | |
console.error("An error was encountered.", error); | |
} | |
} | |
}); | |
}; | |
// Now load the YouTube IFrame API: | |
var youTubeIFrameAPIScript = document.createElement("script"); | |
youTubeIFrameAPIScript.type = "text/javascript"; | |
youTubeIFrameAPIScript.src = "https://www.youtube.com/iframe_api"; | |
document.head.appendChild(youTubeIFrameAPIScript); |
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
{ | |
"name": "YouTube IFrame Inject", | |
"description": "Test code injection into a YouTube iframe", | |
"version": "1.0.0", | |
"permissions": [ | |
"*://*.youtube.com/*", | |
"<all_urls>" | |
], | |
"background": { | |
"page": "background.html" | |
}, | |
"content_scripts": [ | |
{ | |
"matches": ["*://*.youtube.com/embed/*"], | |
"all_frames": true, | |
"js": ["youTubeIFrameInject.js"] | |
} | |
], | |
"content_security_policy": "script-src 'self' 'unsafe-eval' https://www.youtube.com/iframe_api https://s.ytimg.com; object-src 'self'", | |
"manifest_version": 2 | |
} |
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
console.log("Test has loaded"); | |
var requestId = window.requestAnimationFrame(function(){ | |
console.log("requestAnimationFrame has completed successfully."); | |
}); | |
console.log("Request Id:", requestId); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment