Greasy Fork镜像 还支持 简体中文。

AtCoder Bookmarks

try to take over the world!

目前為 2021-02-03 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name AtCoder Bookmarks
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  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. localStorage.setItem("atcoder", JSON.stringify(datalist));
  43. } else {
  44. const userName = document
  45. .getElementsByClassName("dropdown-toggle")[1]
  46. .textContent.slice(10, -17);
  47. const problemUrl = location.href;
  48. const problemName = document
  49. .getElementsByClassName("h2")[0]
  50. .textContent.slice(4, -9);
  51. const value =
  52. "atcoder" + "$" + userName + "$" + problemName + "$" + problemUrl;
  53.  
  54. let html = '<button type="button" class="Bookmark">☆</button>';
  55. $(".h2").append(html);
  56.  
  57. let onoff = "off";
  58. for (const key of GM_listValues()) {
  59. if (key == value) {
  60. onoff = "on";
  61. $(".Bookmark").text("★");
  62. }
  63. }
  64. $(".Bookmark").click(function () {
  65. switch (onoff) {
  66. case "off":
  67. onoff = "on";
  68. $(".Bookmark").text("★");
  69. GM.setValue(value);
  70. break;
  71. case "on":
  72. onoff = "off";
  73. $(".Bookmark").text("☆");
  74. GM.deleteValue(value);
  75. break;
  76. }
  77. });
  78. }
  79. })();

QingJ © 2025

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