前言

当有时候需要复制当前网页的标题和网址来想分享给别人时
就得手动打出标题再复制一下网址

但现在只用点一下就可以直接粘贴给别人
下面记录下采用浏览器书签来获取网页所需内容链接

代码展示

复制网页标题

1
javascript:(function(){ const el = document.createElement('textarea'); el.value = decodeURIComponent(document.title); document.body.appendChild(el); el.select(); document.execCommand('copy'); document.body.removeChild(el); })();


复制标题 + 链接

1
javascript:(function(){ const el = document.createElement('textarea'); el.value = decodeURIComponent(document.title + '\n' + document.URL); document.body.appendChild(el); el.select(); document.execCommand('copy'); document.body.removeChild(el); })();


网页夜间模式

1
javascript:var a=document.createElement('div');a.innerHTML='<div style="position:fixed;background-color:#000;top:0;left:0;z-index:999999;pointer-events:none;opacity:0.35;width:100%;height:100%"></div>';document.body.appendChild(a);


显示明文密码

1
javascript:var intput = document.getElementsByTagName('Input');for(var i=0;i<intput.length;i++) {if(intput[i].type.toUpperCase()=='PASSWORD'){intput[i].setAttribute("type","text");}}


解除网页限制

1
javascript:"use strict";!function(){var t=function(t){t.stopPropagation(),t.stopImmediatePropagation&&t.stopImmediatePropagation()};["copy","cut","contextmenu","selectstart","mousedown","mouseup","keydown","keypress","keyup"].forEach(function(e){document.documentElement.addEventListener(e,t,{capture:!0})}),alert("解除限制成功啦!")}();


网页内容自由在线编辑

1
javascript:"use strict";!function(){"true"===document.body.getAttribute("contenteditable")?(document.body.setAttribute("contenteditable",!1),alert("网页不能编辑啦!")):(document.body.setAttribute("contenteditable",!0),alert("网页可以编辑啦!"))}();


网页分屏

1
javascript:(function(w,d){var href=location.href;var website=w.prompt('请输入网址','http://')||href;d.write('<HTML><HEAD></HEAD><FRAMESET COLS=\'50%,*\'><FRAME SRC='+location.href+'><FRAME SRC='+website+'></FRAMESET></HTML>');})(window,document)

使用方法

  • 新建一个书签,名称随意
  • 将代码填入网址
  • 使用时,点击一下该书签即可

效果展示