检查当前页面/当前网页,是否保存在了github的SingleFile-Archives中,避免重复保存,需要自己配置几个变量
// ==UserScript==
// @name SingleFile-Archives检查是否保存
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 检查当前页面/当前网页,是否保存在了github的SingleFile-Archives中,避免重复保存,需要自己配置几个变量
// @author You
// @include *://*.cnblogs.com/*
// @include *://*.zhihu.com/*
// @grant GM_addElement
// @license GPL-3.0 License
// ==/UserScript==
function add_container() {
let Container = document.createElement('div');
Container.id = "container";
Container.style.position = "fixed";
Container.style.right = "150px";
Container.style.top = "300px";
document.body.appendChild(Container);
}
function add_button(count) {
'use strict';
add_container();
var button1 = document.createElement("button");
button1.textContent = "是否保存:"+count;
button1.style.display = "block";
button1.style.fontSize = "1rem";
button1.title = ""
button1.onclick = function () {
return;
};
///////////
var contain_ = document.querySelector("#container")
contain_.appendChild(button1);
}
(async () => {
const { Octokit, App } = await import("https://esm.sh/octokit");
debugger
const octokit = new Octokit({ auth: `需要自己配置,以访问自己的私有仓库` });
var res = await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
owner: '用户名',
repo: 'SingleFile-Archives',
path: '',
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
})
var count = 0
for (const vvv of res.data) {
// console.log(v);
if (vvv.name.indexOf(document.title) != -1) {
count++
}
}
add_button(count)
})();
//csp