ARTLUNG LAB Share

Bookmarklets, Miscellaneous

To use these, just drag them to your bookmarks file. I can't take credit for these, but I can never find where I found them, so I put copies here. Send me a note if you know from whence they came.

Toggle Table Borders v.1:

Source

<a href="javascript:for(i=0;i<document.all.length;i++)if(document.all[i].tagName=='TABLE')void(document.all[i].border=(document.all[i].border=='0')?'1':'0');">TogTable</a>

ToggleCSS v.1

TogCSS

Source

<a href="javascript:var%20i=0;if(document.styleSheets.length%3E0){cs=!document.styleSheets[0].disabled;for(i=0;i%3Cdocument.styleSheets.length;i++)%20document.styleSheets[i].disabled=cs;}void(cs=true);">TogCSS</a>

Toggle Table Borders v.2 (new and improved, submitted by Reid)

TogTable

Source

<a href="javascript:for(i=0;i<document.getElementsByTagName('TABLE').length;i++)void(document.getElementsByTagName('TABLE')[i].border=(document.getElementsByTagName('TABLE')[i].border=='0')?'1':'0');">TogTable</a>

goToRSSFeed v.1

goToRSSFeed

Source

<a href="javascript:els=document.getElementsByTagName('link');feeds='';for(i=0;i<els.length;i++){ty=(els[i].getAttribute('type')||'').toLowerCase();url=els[i].getAttribute('href');if(url&&(ty=='application/rss+xml'||ty=='text/xml'||ty=='text/x-opml')){if(window.confirm('Go to the RSS Feed: '+url+'?')){feeds+=url+',';}}}if(!feeds){window.alert('No subscriptions made');}else{feeds=feeds.substr(0,feeds.length-1);window.location=feeds;}">goToRSSFeed</a>

goToRSSFeed v.2

goToRSSFeed

Source

var els = document.getElementsByTagName('link');
feeds = '';
for (i = 0; i < els.length; i++) {
    ty = (els[i].getAttribute('type') || '').toLowerCase();
    url = els[i].getAttribute('href');
    if (url && (ty == 'application/rss+xml' || ty == 'text/xml' || ty == 'text/x-opml')) {
        if (window.confirm('Go to the RSS Feed: ' + url + '?')) {
            feeds += url + ',';
        }
    }
}

if (!feeds) {
    window.alert('No subscriptions made');
} else {
    feeds = feeds.substr(0, feeds.length - 1);
    window.location = feeds;
}

Show Rel Canonical

Show Rel Canonical

Source

// find link rel=canonical, no matter the case of the tag
(function() {
    var links = document.getElementsByTagName('link');
    for (var i = 0; i < links.length; i++) {
        if (links[i].rel && links[i].rel.toLowerCase() === 'canonical') {
            const canonicalUrl = links[i].href;
            let style = document.createElement('style');
            style.innerHTML = `
                body::before {
                    content: "Canonical URL: ${canonicalUrl}";
                    position: fixed;
                    top: 0;
                    left: 0;
                    width: 100%;
                    background-color: green;
                    color: white;
                    padding: 0.3rem;
                    font-size: 2rem;
                    z-index: 1000;
                    text-align: center;
                }
            `;
            document.head.appendChild(style);
        return;
        }
    }
})();

Show Rel Webmention

Show Rel Webmention

Source

// find link rel=webmention, no matter the case of the tag
(function() {
    var links = document.getElementsByTagName('link');
    for (var i = 0; i < links.length; i++) {
        if (links[i].rel && (links[i].rel.toLowerCase() === 'webmention'
        || links[i].rel.toLowerCase().indexOf('webmention') !== -1
        )) {
            const webmentionUrl = links[i].href;
            let style = document.createElement('style');
            style.innerHTML = `
                body::before {
                    content: "Webmention URL: ${webmentionUrl}";
                    position: fixed;
                    top: 0;
                    left: 0;
                    width: 100%;
                    background-color: green;
                    color: white;
                    padding: 0.3rem;
                    font-size: 2rem;
                    z-index: 1000;
                    text-align: center;
                }
            `;
            document.head.appendChild(style);
            return;
        }
    }
})();

Re-enable Right Click

Many websites disable right click, let's try to re-enable it by checking for oncontextmenu events and nuking them.

Re-enable Right Click

Source Code

// This is a draft. Might not pan out.
// naive attempt based on oncontextmenu attributes
document.querySelectorAll('[oncontextmenu]').forEach(function (element) {
    console.log('removing oncontextmenu from element', element);
    element.removeAttribute('oncontextmenu');
});

// naive attempt based on onmousedown attributes
document.querySelectorAll('[onmousedown]').forEach(function (element) {
    console.log('removing onmousedown from element', element);
    element.removeAttribute('onmousedown');
});

// naive attempt based on onmouseup attributes
document.querySelectorAll('[onmouseup]').forEach(function (element) {
    console.log('removing onmouseup from element', element);
    element.removeAttribute('onmouseup');
});

// naive attempt based on onselectstart attributes

document.querySelectorAll('[onselectstart]').forEach(function (element) {
    console.log('removing onselectstart from element', element);
    element.removeAttribute('onselectstart');
});

// naive attempt based on ondragstart attributes
document.querySelectorAll('[ondragstart]').forEach(function (element) {
    console.log('removing ondragstart from element', element);
    element.removeAttribute('ondragstart');
});

// naive attempt based on ondrag attributes
document.querySelectorAll('[ondrag]').forEach(function (element) {
    console.log('removing ondrag from element', element);
    element.removeAttribute('ondrag');
});

// naive attempt based on ondragend attributes
document.querySelectorAll('[ondragend]').forEach(function (element) {
    console.log('removing ondragend from element', element);
    element.removeAttribute('ondragend');
});