「かんたんコメント」機能が果てしなく気に食わないので、とりあえず人々の利用状況を確認するために作成。

Format
JavaScript
Post date
2020-08-08 14:42
Publication Period
Unlimited
  1. // ==UserScript==
  2. // @name nicovideo_player_improvement
  3. // @version 1.1
  4. // @include http://www.nicovideo.jp/watch/*
  5. // @include https://www.nicovideo.jp/watch/*
  6. // @grant none
  7. // @run-at document-start
  8. // ==/UserScript==
  9. // Copyright waived using CC0 1.0 Universal, 2020 dyknon
  10. window.eval(`
  11. if(!window.fetch._replaced){
  12. let _fetch = window.fetch;
  13. window.fetch = function(url, init){
  14. console.log("fetch call: " + url);
  15. if(
  16. url.indexOf("http://ads.nicovideo.jp/api/video/getAd.php") == 0 ||
  17. url.indexOf("https://ads.nicovideo.jp/api/video/getAd.php") == 0
  18. ){
  19. //再生前広告ブロック
  20. return Promise.resolve({
  21. text:
  22. () => Promise.resolve(
  23. '<?xml version="1.0" encoding="UTF-8"?>'
  24. + '<VAST version="3.0"></VAST>'
  25. )
  26. });
  27. }else if(url.indexOf("https://nmsg.nicovideo.jp/api.json/") == 0){
  28. //「かんたんコメント」を黒くする
  29. let request = JSON.parse(init.body);
  30. let pingmap = {};
  31. let pingname;
  32. for(let packet of request){
  33. if(packet.ping){
  34. pingname = packet.ping.content;
  35. }else{
  36. pingmap[pingname] = packet;
  37. }
  38. }
  39. return _fetch(... arguments).then(res => {
  40. return {
  41. json: () => res.json().then(json => {
  42. let creq;
  43. for(let packet of json){
  44. if(packet.ping){
  45. creq = pingmap[packet.ping.content];
  46. }else if(
  47. creq && creq.thread_leaves
  48. && creq.thread_leaves.fork == 2
  49. && packet.chat
  50. ){
  51. packet.chat.mail = "small black " + packet.chat.mail;
  52. }
  53. }
  54. return json;
  55. })
  56. };
  57. });
  58. }else{
  59. return _fetch(... arguments);
  60. }
  61. };
  62. window.fetch._replaced = true;
  63. }
  64. `);
Download Printable view

URL of this paste

Embed with JavaScript

Embed with iframe

Raw text