Use JavaScript to disable and make video links unclickable on Niconico Video’s mylist screen.
I’m not sure how much demand there is for this.
Disable video links on Niconico Video’s mylist screen to make it easier to copy and paste video titles, etc.
Niconico seems to have special specifications, and just using removeAttribute(‘href’) won’t disable them.
Do it like this:
for (i = 0; i < document.getElementsByTagName('a').length; i++){
document.getElementsByTagName('a')[i].removeAttribute('data-href') ;
}
for (i = 0; i < document.getElementsByTagName('a').length; i++){
document.getElementsByTagName('a')[i].removeAttribute('href') ;
}
Bookmarklet:
javascript:for(i=0;i<document.getElementsByTagName('a').length;i++){document.getElementsByTagName('a')[i].removeAttribute('data-href')}for(i=0;i<document.getElementsByTagName('a').length;i++){document.getElementsByTagName('a')[i].removeAttribute('href')}
The key is to first remove data-href.
Alternatively, since it’s troublesome, you can remove all attributes of “a” tags at once.
This way, it may be reusable on other sites with specifications like Niconico Video.
It’s a bit long though:
// Include and enable jQuery in JavaScript
(function() {
// Load the script
var script = document.createElement("SCRIPT");
script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js';
script.type = 'text/javascript';
script.onload = function() {
var $ = window.jQuery;
// Use $ here...
};
document.getElementsByTagName("head")[0].appendChild(script);
})();
// define Remove all attributes function
jQuery.fn.removeAttributes = function() {
return this.each(function() {
var attributes = $.map(this.attributes, function(item) {
return item.name;
});
var img = $(this);
$.each(attributes, function(i, item) {
img.removeAttr(item);
});
});
}
$("a").removeAttributes();
Reference: