AtCoder Bookmarks

try to take over the world!

  1. // ==UserScript==
  2. // @name AtCoder Bookmarks
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1.3
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://atcoder.jp/contests/*/tasks/*
  8. // @match https://atcoder-bookmarks.oxyshower.xyz
  9. // @match http://localhost:3000/
  10. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  11. // @grant GM.setValue
  12. // @grant GM.getValue
  13. // @grant GM_listValues
  14. // @grant GM.deleteValue
  15. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js
  16. // ==/UserScript==
  17.  
  18. (function () {
  19. "use strict";
  20.  
  21. const URL = location.href;
  22. if (URL.match("https://atcoder-bookmarks.oxyshower.xyz")) {
  23. let id = 0;
  24. let datalist = [];
  25. for (const key of GM_listValues()) {
  26. let username = "",
  27. problemname = "",
  28. problemurl,
  29. idx = 8;
  30. while (key[idx] != "$") username += key[idx++];
  31. idx++;
  32. while (key[idx] != "$") problemname += key[idx++];
  33. idx++;
  34. problemurl = key.substr(idx);
  35. datalist[id++] = {
  36. userName: username,
  37. problemName: problemname,
  38. problemUrl: problemurl,
  39. };
  40. }
  41. localStorage.removeItem("atcoder");
  42. // objectは保存できない -> 文字列で保存
  43. localStorage.setItem("atcoder", JSON.stringify(datalist));
  44. // console.log(JSON.stringify(datalist));
  45. } else {
  46. const userName = document
  47. .getElementsByClassName("dropdown-toggle")[1]
  48. .textContent.slice(10, -17);
  49. const problemUrl = location.href;
  50. const problemName = document
  51. .getElementsByClassName("h2")[0]
  52. .textContent.slice(4, -9);
  53. const value =
  54. "atcoder" + "$" + userName + "$" + problemName + "$" + problemUrl;
  55.  
  56. let html =
  57. '<button type="button" style="border: none; outline: none; color: rgb(218, 200, 42); background-color: white;" class="Bookmark">☆</button>';
  58. $(".h2").append(html);
  59.  
  60. let onoff = "off";
  61. for (const key of GM_listValues()) {
  62. if (key == value) {
  63. onoff = "on";
  64. $(".Bookmark").text("★");
  65. }
  66. }
  67. $(".Bookmark").click(function () {
  68. switch (onoff) {
  69. case "off":
  70. onoff = "on";
  71. $(".Bookmark").text("★");
  72. GM.setValue(value);
  73. break;
  74. case "on":
  75. onoff = "off";
  76. $(".Bookmark").text("☆");
  77. GM.deleteValue(value);
  78. break;
  79. }
  80. });
  81. }
  82. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址