search bookmarks.html
<hr>
drag this link into your bookmarks:
<a href="javascript:(function(){ if (window.bookmarks_handled) { return; } window.bookmarks_handled = true; function changeTag(el_old, newtag) { var el_new = document.createElement(newtag); el_old.replaceWith(el_new); while(el_old.firstChild) { el_new.appendChild(el_old.firstChild); } el_old.getAttributeNames().forEach(function(attr){ el_new.setAttribute(attr, el_old.attributes[attr].value); }); } document.querySelectorAll('dt').forEach(function(el){ changeTag(el, 'details'); }); document.querySelectorAll('h3').forEach(function(el){ changeTag(el, 'summary'); }); document.querySelectorAll('summary').forEach(function(el){ var d = el.closest('details'); if(!d){return;} d.insertBefore(el, d.firstChild); }); document.querySelectorAll('a').forEach(function(el){ var p = el.parentNode; if(p.tagName === 'DETAILS') { p.parentNode.insertBefore(el, p); if (p.children.length === 0) { p.remove(); } } }); document.querySelectorAll('p').forEach(el => el.remove() ); document.querySelectorAll('img').forEach(el => el.remove() ); document.querySelectorAll('a[icon]').forEach(function(el){ var img = document.createElement('img'); img.src = el.attributes['icon'].value; el.prepend(img); }); document.querySelectorAll('a, summary').forEach(function(el){ var t = ''; if (el.attributes['add_date']) { var d = new Date(parseInt(el.attributes['add_date'].value) * 1000); t += 'add_date: '+ ( d.toISOString() + '') + '\n\n'; } if (el.attributes['last_modified']) { var d = new Date(parseInt(el.attributes['last_modified'].value) * 1000); t += 'last_modified: '+ ( d.toISOString() + '') + '\n\n'; } if (el.href) { t += el.href + '\n\n'; } if (el.textContent) { t +=...
JavaScript
return; // ABORT for jsfiddle
(function(){
if (window.bookmarks_handled) {
return;
}
window.bookmarks_handled = true;
/*
function replaceElement(el_old, el_new) {
// el_old.parentNode.replaceChild(el_new, el_old);
el_old.replaceWith(el_new);
}
function moveChildren(el_old, el_new) {
// NB: do not use children, it does not have texnodes
// el_old.childNodes.forEach(function(el){
// el_new.appendChild(el);
// });
while(el_old.firstChild) {
el_new.appendChild(el_old.firstChild);
}
}
function wrap(toWrap, wrapper) {
wrapper = wrapper || document.createElement('div');
toWrap.parentNode.insertBefore(wrapper, toWrap);
return wrapper.appendChild(toWrap);
}
*/
function changeTag(el_old, newtag) {
// replace old element with new empty element:
var el_new = document.createElement(newtag);
el_old.replaceWith(el_new);
// move children (including textnodes):
while(el_old.firstChild) {
el_new.appendChild(el_old.firstChild);
}
// copy attributes:
el_old.getAttributeNames().forEach(function(attr){
el_new.setAttribute(attr, el_old.attributes[attr].value);
});
}
// change all <dt> to <details> , to make it a collapsable tree:
document.querySelectorAll('dt').forEach(function(el){
changeTag(el, 'details');
});
document.querySelectorAll('h3').forEach(function(el){
changeTag(el, 'summary');
});
document.querySelectorAll('summary').forEach(function(el){
var d = el.closest('details');
if(!d){return;}
d.insertBefore(el, d.firstChild);
});
// Original: 'dt > a' , now: 'details > a'.
// No need for details around a single a element, so unwrap it and remove the empty details element:
document.querySelectorAll('a').forEach(function(el){
var p = el.parentNode;
if(p.tagName === 'DETAILS') {
p.parentNode.insertBefore(el, p);
if (p.children.length === 0) {
p.remove();
}
}
});
document.querySelectorAll('p').forEach(el => el.remove() );
document.querySelectorAll('img').forEach(el =>...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.