-
-
Save boyangwang/9c519bbc1964f703849dcf31fa137e07 to your computer and use it in GitHub Desktop.
techmeetup-2017may13-boyang
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
// if (MutationObserver) { | |
// var observer = new MutationObserver(function(mutations) { | |
// let scripts = Array.from(document.querySelectorAll('script')); | |
// console.log(scripts); | |
// let bjs; | |
// if (!(bjs = scripts.find(s => s.src.includes('b.js')))) | |
// return; | |
// // bjs.addEventListener('loaded', function(e) {bjs.remove();}); | |
// bjs.remove(); | |
// manipulate(bjs.src); | |
// this.disconnect(); | |
// }); | |
// observer.observe(document, {childList: true, subtree: true}); | |
// } | |
// function manipulate(src) { | |
// var oReq = new XMLHttpRequest(); | |
// oReq.onerror = function(e) { console.log('xxx Err', e); }; | |
// oReq.onload = function() { | |
// // console.log('xxx Success', this); | |
// let manipulatedCode = this.responseText.replace('\'b\'', '\'c\''); | |
// eval(manipulatedCode); | |
// }; | |
// oReq.open('get', src, true); | |
// oReq.send(); | |
// } | |
function myfunc() { console.log('a\'s target'); } | |
Object.defineProperty(window, 'myTarget', { | |
set: function(newValue) { console.log('rejected!'); }, | |
get: function() { return myfunc; }, | |
configurable: false | |
}); |
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> | |
<!-- <script async crossorigin="anonymous" src="//player.h-cdn.com/loader.js?customer=boyang_test"></script> --> | |
</head> | |
<body> | |
<!-- <script async src="a.js"></script> --> | |
<script src="a.js"></script> | |
<script src="b.js"></script> | |
<!-- | |
<script> | |
window.myTarget(); | |
</script> --> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment