Skip to content

Instantly share code, notes, and snippets.

@glasslion
Last active April 25, 2021 14:08
Show Gist options
  • Save glasslion/9f32089640c2982a17b8e1490f58fa65 to your computer and use it in GitHub Desktop.
Save glasslion/9f32089640c2982a17b8e1490f58fa65 to your computer and use it in GitHub Desktop.
Bookmarklet that makes web page clipping easy.
javascript:void function(){function e(e,n){return function(o){l%3Fn(o):e%26%26e(o)}}function n(e){var n=e||window.event,o=n.target||n.srcElement;o.style.outline="2px solid gray",r=o}function o(e){var n=e||window.event,o=n.target||n.srcElement;o.style.outline=""}function t(e){var n=e||window.event,o=n.target||n.srcElement;o.remove()}function i(e){var n=e||window.event;27==n.keyCode%26%26(r.style.outline="",l=!1)}var r,c=document,l=!0;c.onmouseover=e(c.onmouseover,n),c.onmouseout=e(c.onmouseout,o),c.onclick=e(c.onclick,t),c.oncontextmenu=e(c.onclick,t),c.onkeydown=e(c.onkeydown,i),window.location.href.indexOf(!1)%26%26(c.title=c.getElementById("activity-name").innerHTML.trim());for(var u=c.getElementsByClassName("js-progressiveMedia-thumbnail"),a=0;a<u.length;a++)u[a].remove()}();
var d = document,
useMine = true,
prevEl;
function AddHandler(orig, mine) {
return function(e) {
if (useMine) mine(e);
else if (orig) orig(e);
};
}
function Myonmouseover(e) {
var evt = e || window.event;
var elem = evt.target || evt.srcElement;
elem.style.outline = '2px solid gray';
prevEl = elem;
}
function Myonmouseout(e) {
var evt = e || window.event;
var elem = evt.target || evt.srcElement;
elem.style.outline = '';
}
function Myonclick(e) {
var evt = e || window.event;
var elem = evt.target || evt.srcElement;
elem.remove();
}
function Myonkeydown(e) {
var evt = e || window.event;
if (evt.keyCode == 27) {
prevEl.style.outline = '';
useMine = false;
}
}
d.onmouseover = AddHandler(d.onmouseover, Myonmouseover);
d.onmouseout = AddHandler(d.onmouseout, Myonmouseout);
d.onclick = AddHandler(d.onclick, Myonclick);
d.oncontextmenu = AddHandler(d.onclick, Myonclick);
d.onkeydown = AddHandler(d.onkeydown, Myonkeydown);
// Weixin
if(window.location.href.indexOf('://mp.weixin.qq.com'>0)){
d.title=d.getElementById('activity-name').innerHTML.trim();
};
// medium
var thumbs = d.getElementsByClassName('js-progressiveMedia-thumbnail');
for (var i = 0; i < thumbs.length; i++) {
thumbs[i].remove();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment