Bookmarklets

All code snippets listed below, are bookmarklets, i.e. you can copy-paste them to the "address" (or "URL") of your bookmark, and give it a name so it serves as button in your bookmarks bar, and ready to execute.

Censor Selection

This bookmarklet censors the selected text so you can take screenshots of open pages easily without the hussle of editing the captured image.

It is an Immediately Invoked Function Expression ? , which means, you can customize the "censoring style" by changing the value of the styles parameter upon function invocation. The styles by default, are; display: inline-block; background-color: currentColor; transform: skewX(-6deg);, and it looks like this.

View Code
javascript: (function(styles) {
        const censoredWrapper = document.createElement('span');
        censoredWrapper.style = styles;
        
        const selection = document.getSelection();
        if (selection.rangeCount === 0 || selection.isCollapsed) {
          alert('Please, select some text first.');
          return;
        }
        
        const range = selection.getRangeAt(0);
        
        try {
          range.cloneRange().surroundContents(censoredWrapper);
        } catch (err) {
          alert(
            'Error Occured. Perhaps you are trying to censor a node that is not a text node, or maybe its spanning a few consecutive nodes. Only text nodes or parts of text nodes are supported.'
          );
        }
        document.getSelection().empty();
        })(
        'display: inline-block; background-color: currentColor; transform: skewX(-6deg);'
        );
javascript