SingleFile-Archives检查是否保存

检查当前页面/当前网页,是否保存在了github的SingleFile-Archives中,避免重复保存,需要自己配置几个变量

目前为 2023-07-03 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name SingleFile-Archives检查是否保存
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 检查当前页面/当前网页,是否保存在了github的SingleFile-Archives中,避免重复保存,需要自己配置几个变量
  6. // @author You
  7. // @include *://*.cnblogs.com/*
  8. // @include *://*.zhihu.com/*
  9. // @grant GM_addElement
  10. // @license GPL-3.0 License
  11. // ==/UserScript==
  12. function add_container() {
  13. let Container = document.createElement('div');
  14. Container.id = "container";
  15. Container.style.position = "fixed";
  16. Container.style.right = "150px";
  17. Container.style.top = "300px";
  18. document.body.appendChild(Container);
  19. }
  20.  
  21. function add_button(count) {
  22. 'use strict';
  23. add_container();
  24.  
  25. var button1 = document.createElement("button");
  26. button1.textContent = "是否保存:"+count;
  27. button1.style.display = "block";
  28. button1.style.fontSize = "1rem";
  29. button1.title = ""
  30.  
  31. button1.onclick = function () {
  32. return;
  33. };
  34.  
  35. ///////////
  36.  
  37. var contain_ = document.querySelector("#container")
  38. contain_.appendChild(button1);
  39. }
  40.  
  41. (async () => {
  42. const { Octokit, App } = await import("https://esm.sh/octokit");
  43. debugger
  44. const octokit = new Octokit({ auth: `需要自己配置,以访问自己的私有仓库` });
  45. var res = await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
  46. owner: '用户名',
  47. repo: 'SingleFile-Archives',
  48. path: '',
  49. headers: {
  50. 'X-GitHub-Api-Version': '2022-11-28'
  51. }
  52. })
  53.  
  54. var count = 0
  55. for (const vvv of res.data) {
  56. // console.log(v);
  57. if (vvv.name.indexOf(document.title) != -1) {
  58. count++
  59. }
  60. }
  61. add_button(count)
  62.  
  63. })();
  64.  
  65. //csp

QingJ © 2025

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