AtcoderSubmissionShareWithTitle

AtCoderの提出をシェアするときに問題のタイトルを含める

  1. // ==UserScript==
  2. // @name AtcoderSubmissionShareWithTitle
  3. // @namespace https://github.com/tmikada
  4. // @version 1.01
  5. // @description AtCoderの提出をシェアするときに問題のタイトルを含める
  6. // @include https://atcoder.jp/contests/*/submissions/*
  7. // @auther tmikada
  8. // @license MIT
  9. // ==/UserScript==
  10. (function() {
  11. 'use strict';
  12.  
  13. var mondaiTitle = "";
  14. var thElems = document.getElementsByTagName("th");
  15. for(var i = 0; i < thElems.length; i++) {
  16. var elm = thElems[i];
  17. if(thElems[i].innerHTML == "問題") {
  18. mondaiTitle = thElems[i].nextElementSibling.textContent;
  19. }
  20. }
  21.  
  22. var tweetButton = document.getElementsByClassName("a2a_button_twitter");
  23. var linkNode = tweetButton[0].parentNode;
  24. var title = linkNode.getAttribute("data-a2a-title");
  25. linkNode.setAttribute("data-a2a-title",mondaiTitle+"\r\n"+title);
  26.  
  27. })();