diff --git a/README.md b/README.md index e2975bd..0b56799 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,21 @@ A small snippet to add your own copy method, in case the original one has been tampered with. ``` -document.onkeyup = function(e) { +var frames = document.getElementsByTagName("iframe"); +let copyFunction = function(e) { if (e.ctrlKey && e.which == 67) { - var text = window.getSelection().toString() + var text = this.window.getSelection().toString() navigator.clipboard.writeText(text) } } +document.onkeyup = copyFunction +for (let i = 0; i < frames.length; ++i) { + if (frames[i].id == 'mcas-presence-frame-do-not-remove') { + frames[i].parentNode.removeChild(frames[i]) + } else { + frames[i].contentWindow.onkeyup = copyFunction + } +} ``` 1. Copy the above snippet. diff --git a/copy.js b/copy.js index b404105..3ec7cbc 100644 --- a/copy.js +++ b/copy.js @@ -1,6 +1,15 @@ -document.onkeyup = function(e) { +var frames = document.getElementsByTagName("iframe"); +let copyFunction = function(e) { if (e.ctrlKey && e.which == 67) { - var text = window.getSelection().toString() + var text = this.window.getSelection().toString() navigator.clipboard.writeText(text) } } +document.onkeyup = copyFunction +for (let i = 0; i < frames.length; ++i) { + if (frames[i].id == 'mcas-presence-frame-do-not-remove') { + frames[i].parentNode.removeChild(frames[i]) + } else { + frames[i].contentWindow.onkeyup = copyFunction + } +}