gpt4 book ai didi

Javascript:如何创建浏览器书签来编辑 Github 中的文件?

转载 作者:行者123 更新时间:2023-11-29 22:54:20 28 4
gpt4 key购买 nike

我有一个 javascript 小书签,可以帮助我在 GitHub 上提交:

 document.getElementById('submit-file').click();. 

我想知道如何制作一个类似的小书签来编辑 GitHub 文件?

我是 javascript 的新手,仍处于学习阶段,所以我花了几天时间才弄清楚如何做到这一点

根据评论更新

FWIW,事实上,我试图修改一个 Alfred 工作流程(MacOS 应用程序来自动执行任务)并且该应用程序允许我们单击 github 页面中的“提交”按钮,我试图修改它以便现在我可以编辑github中的当前文档。

应用程序概要:

第一部分:

document.getElementById('submit-file').click();

第二部分:

const bookmarklet_code="{query}"
const frontmost_app_name = Application('System Events').applicationProcesses.where({ frontmost: true }).name()[0]
const frontmost_app = Application(frontmost_app_name)

if (['Google Chrome','Google Chrome Canary','Chromium'].indexOf(frontmost_app_name) > -1) {
frontmost_app.windows[0].activeTab.url = 'javascript:' + bookmarklet_code
} else if (['Safari', 'Safari Technology Preview', 'Webkit'].indexOf(frontmost_app_name) > -1) {
frontmost_app.doJavaScript(bookmarklet_code, { in: frontmost_app.documents[0] })
} else {
throw new Error('You need a supported browser as your frontmost app')
}

最佳答案

试试这个书签:

javascript:document.querySelector('[aria-label="Edit this file"]').click();

它根据Aria-Label 找到编辑 按钮并点击它。

关于Javascript:如何创建浏览器书签来编辑 Github 中的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56914626/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com