Jump to content

User:Dialectric/vector.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Dialectric (talk | contribs) at 18:30, 29 September 2020. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//------------------------------------------------------
// recolor test
// task: to override inline styles for some table elements to better fit dark theme
// status: testing only - do not use
//------------------------------------------------------


function ready(callback){
    // in case the document is already rendered
    if (document.readyState!='loading') callback();
    // modern browsers
    else if (document.addEventListener) document.addEventListener('DOMContentLoaded', callback);
    // IE <= 8
    else document.attachEvent('onreadystatechange', function(){
        if (document.readyState=='complete') callback();
    });
}

ready(function(){
    // do something
        var target = document.querySelectorAll('th');
        Array.prototype.forEach.call(target, function(element){
         element.removeAttribute('style');
         element.style.border = '2px solid #0F0'
       
        });
        var target = document.querySelectorAll('tr');
        Array.prototype.forEach.call(target, function(element){
         element.removeAttribute('style');
         element.style.border = '2px solid #F00'
        });
    });