Created
May 1, 2020 11:40
-
-
Save behitek/d3d7c1c3210fc277f758bae42eddb5d8 to your computer and use it in GitHub Desktop.
Thêm copyright khi người dùng copy dữ liệu từ website
This file contains hidden or 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 addLink() { | |
//Get the selected text and append the extra info | |
var selection = window.getSelection(), | |
pagelink = '<br /><br /> Nguồn: ' + document.location.href, | |
copytext = selection + pagelink, | |
newdiv = document.createElement('div'); | |
//hide the newly created container | |
newdiv.style.position = 'absolute'; | |
newdiv.style.left = '-99999px'; | |
//insert the container, fill it with the extended text, and define the new selection | |
document.body.appendChild(newdiv); | |
newdiv.innerHTML = copytext; | |
selection.selectAllChildren(newdiv); | |
window.setTimeout(function () { | |
document.body.removeChild(newdiv); | |
}, 100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hay đó, ngày xưa hay chặn copy này nọ, giờ chán rồi :)) Nhất là xài Mac safari bấm reader lên thì bao plugin chống copy hết tác dụng 💯