Skip to content

Instantly share code, notes, and snippets.

@DinisCruz
Created September 10, 2019 14:04
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save DinisCruz/6866dede5cdff60d97790a14490f7844 to your computer and use it in GitHub Desktop.
Save DinisCruz/6866dede5cdff60d97790a14490f7844 to your computer and use it in GitHub Desktop.
Show a better network graph (see thread https://twitter.com/DinisCruz/status/1171411025570275329 )
function hide(selector) { $(selector).setAttribute('style','display:none')}
function remove(selector) { $(selector).remove()}
function remove_class(selector) { $(selector).setAttribute('class','')}
function move_left(count)
{
var eventObj = document.createEvent("Events");
eventObj.initEvent("keydown", true, true);
eventObj.which = 37; // left key
for (i=0; i < count ; i++) {
document.dispatchEvent(eventObj);
}
}
function resize_canvas(width)
{
document.getElementById("network").style="width:" + width; window.dispatchEvent(new Event("resize"))
}
remove('.pagehead')
remove('.js-header-wrapper')
remove('.menu')
remove('.Subhead')
remove('.info')
remove('.btn-link')
remove('.footer')
remove_class('.container-lg')
remove_class('.pr-4')
resize_canvas('2150px')
move_left(14)
@LoganTann
Copy link

Uncaught TypeError: $(...) is null while pasting the code on the console

@RomainBrocheton
Copy link

@LoganTann just add jQuery

@danielsbdev
Copy link

@LoganTann how? {If refused to load the script because it violates the following Content Security Policy directive: "script-src github.githubassets.com". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.}

@LoganTann
Copy link

I just went to my profile page, copied and pasted in the dev console the code, and it says that $(...) is null.
It's due to the line 20.

I finally managed to fix this manually by manipulating the dom without using the $() some month ago

@isovector
Copy link

@LoganTann can you share your solution?

@travislang
Copy link

travislang commented Mar 8, 2024

Here is a version that removes jquery and uses native javascript. copy/paste in the console

function hide(selector) {
    var element = document.querySelector(selector);
    if (element) {
        element.style.display = 'none';
    }
}

function remove(selector) {
    var element = document.querySelector(selector);
    if (element && element.parentNode) {
        element.parentNode.removeChild(element);
    }
}

function remove_class(selector) {
    var element = document.querySelector(selector);
    if (element) {
        element.removeAttribute('class');
    }
}

function move_left(count) {
    var eventObj = document.createEvent('Events');
    eventObj.initEvent('keydown', true, true);
    eventObj.which = 37; // left key
    for (var i = 0; i < count; i++) {
        document.dispatchEvent(eventObj);
    }
}

function resize_canvas(width) {
    var canvas = document.getElementById('network');
    if (canvas) {
        canvas.style.width = width;
        window.dispatchEvent(new Event('resize'));
    }
}

remove('.pagehead');
remove('.js-header-wrapper');
remove('.menu');
remove('.Subhead');
remove('.info');
remove('.btn-link');
remove('.footer');
remove_class('.container-lg');
remove_class('.pr-4');

resize_canvas('2150px');
move_left(14);

@DinisCruz
Copy link
Author

Great, thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment