|
@@ -49,41 +49,14 @@
|
|
|
myCopy(`<a href="${location.href}">${document.title}</a>`)
|
|
|
}
|
|
|
|
|
|
+ unsafeWindow.to_memory = to_memory;
|
|
|
+
|
|
|
document.onkeydown = function (ev) {
|
|
|
if (ev.key === 'c' && ev.shiftKey) {
|
|
|
ev.preventDefault() // 关闭浏览器快捷键
|
|
|
copyTitle()
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- let btnStyle = `
|
|
|
- #copy-title-and-location {
|
|
|
- position: fixed; top: 300px; left: -165px; opacity: 0.3; z-index: 2147483647;
|
|
|
- background-image: none; cursor:pointer; color: #fff; background-color: #0084ff !important;
|
|
|
- margin: 5px 0px; width: auto; border-radius: 3px; border: #0084ff; outline: none; padding: 3px 6px; height: 35px;
|
|
|
- font-family: Arial, sans-serif; font-size: 22px; transition: left, 0.5s;
|
|
|
- }
|
|
|
- #copy-title-and-location:hover {left: 0px; opacity: 1;}
|
|
|
- #copy-title-and-location svg {width: auto; vertical-align: middle; margin-left: 10px; border-style: none;text-align: center;display: inline-block !important;margin-bottom: 2px;}`;
|
|
|
- let styleTag = createEle('style', btnStyle, {type: "text/css"});
|
|
|
-
|
|
|
- // 将按钮图标由原来的img改为了svg,以增强适应性,同时也将对svg的样式设置移到了上面的 btnStyle 中
|
|
|
- let iconSVG = '<?xml version="1.0" encoding="UTF-8"?><svg width="22" height="22" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="48" height="48" fill="white" fill-opacity="0.01"/><path d="M8 6C8 4.89543 8.89543 4 10 4H30L40 14V42C40 43.1046 39.1046 44 38 44H10C8.89543 44 8 43.1046 8 42V6Z" fill="none" stroke="#333" stroke-width="4" stroke-linejoin="round"/><path d="M16 20H32" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M16 28H32" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
|
|
- let btn = createEle('button', '', {id: "copy-title-and-location"});
|
|
|
- btn.innerHTML = '插入标题和地址' + iconSVG;
|
|
|
-
|
|
|
- btn.addEventListener('click', () => {
|
|
|
- to_memory()
|
|
|
- });
|
|
|
- if (window.self === window.top) {
|
|
|
- if (document.querySelector('body')) {
|
|
|
- document.body.appendChild(btn);
|
|
|
- document.body.appendChild(styleTag);
|
|
|
- } else {
|
|
|
- document.documentElement.appendChild(btn);
|
|
|
- document.documentElement.appendChild(styleTag);
|
|
|
- }
|
|
|
- }
|
|
|
})();
|
|
|
|
|
|
|