Tag Stripper
Strips a website of everything except a few whitelisted things. Context menu activated
Click here to install
Browse More Scripts
// ==UserScript==
// @name Tag Stripper
// @namespace 5b5772ac9a58f2cbcdd4e040c0eb874e1c41acea
// @version 1.0
// @description Strips a website of everything except a few whitelisted things. Context menu activated
// @author /u/AyrA_ch
// @match http://*/*
// @match https://*/*
// @grant none
// @run-at context-menu
// ==/UserScript==
//Version History
// 1.0: Now a context menu script
// 0.9: Initially published version
(function () {
'use strict';
//This list contains elements themselves that shouldn't be removed
//The explanation for autoStrip() will be here if needed.
var wlTags = [];
//Tag white-list. There's no technical necessity for a certain order.
//Everything not in this list will be removed from the document
var wl = [
//Required elements
"html", "body", "head", "title",
//Generic Elements
"p", "div", "pre", "hr",
//Links
"a",
//Text formatting
"code", "b", "strong", "i", "u", "span", "br",
//Lists
"ul", "ol", "li", "dd", "dt", "dl",
//Headings
"h1", "h2", "h3", "h4", "h5", "h6",
//Table
"table", "thead", "tbody", "tfoot", "tr", "td", "th",
//Forms
"form", "input", "button", "select", "textarea", "option", "optgroup"
];
//Attribute white-list
//Attributes not in this list will be stripped completely from all whitelisted tags
var awl = [
//Generic
"id", "name", "title", "lang",
//Form
"action", "method", "type", "value", "placeholder", "pattern", "rows", "cols",
//Links
"href", "target", "rel"
];
var stripAll = function () {
//Gets Everything
var ele = document.querySelectorAll('*');
for (var i = 0; i < ele.length; i++) {
var e = ele[i];
if (wlTags.indexOf(e) < 0) {
//Don't bother to remove attributes if the tag is not whitelisted
//We are going to remove it anyways completely
if (wl.indexOf(e.tagName.toLowerCase()) < 0) {
console.debug("Removing Tag", e.tagName);
e.remove();
} else {
var attrs = e.attributes;
for (var j = 0; j < attrs.length; j++) {
var attr = attrs[j].name.toLowerCase();
if (awl.indexOf(attr) < 0) {
console.debug("Removing Attribute", attr);
e.removeAttribute(attr);
}
}
}
}
}
};
stripAll();
})();
/*
LICENSE:
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
The full license text can be found here: http://creativecommons.org/licenses/by-nc-sa/4.0/
The link has an easy to understand version of the license and the full license text.
DISCLAIMER:
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
*/
User Script Managers
A userscript manager is the browser extension that injects scripts into websites
to change their behavior to your liking.
Recommendation
All scripts on this site have been developed and tested with Tampermonkey on firefox.
Try other browsers and other script managers at your own risk.
No script should use firefox or chrome specific features,
which means they should also work in other modern browsers.
If you prefer, you can use greasemonkey.
Get Tampermonkey,
Get Greasemonkey (Firefox only)
Script Installation
Once you have obtained a user script manager,
clicking on the install button will pop up an installation prompt.
To allow script manager detection,
you can install this helper script.
It's not necessary but simplifies your future visits to this site.
Script Installation
We detected, that you have a script manager installed and active.
Click the "Install Script" button to obtain the script.