-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
function attachEvent(selector, event, fn) { | ||
const matches = typeof selector === 'string' ? document.querySelectorAll(selector) : selector; | ||
if (matches && matches.length) { | ||
matches.forEach((elem) => { | ||
elem.addEventListener(event, (e) => fn(e, elem), false); | ||
}); | ||
} | ||
} | ||
|
||
window.onload = function() { | ||
var host = window.location.host; | ||
var pathname = window.location.pathname; | ||
|
||
attachEvent('.copyPost', 'click', function() { | ||
var tempInput = document.createElement("input"); | ||
tempInput.value = host + pathname; | ||
document.body.appendChild(tempInput); | ||
tempInput.select(); | ||
tempInput.setSelectionRange(0, 99999); | ||
document.execCommand("copy"); | ||
document.body.removeChild(tempInput); | ||
}); | ||
}; |
Large diffs are not rendered by default.