Skip to content

Commit

Permalink
buttons working, post request code added(testing needed)
Browse files Browse the repository at this point in the history
  • Loading branch information
SYu449 committed Jul 22, 2021
1 parent 5ecdee8 commit d5f0fae
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 5 deletions.
8 changes: 8 additions & 0 deletions auth_key.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
document.addEventListener('DOMContentLoaded', function() {
document.getElementById('key_button').addEventListener('click', onClick, false)
function onClick () {
console.log('test')
const token = prompt('Enter Access Token')
console.log(token)
}
}, false)
2 changes: 2 additions & 0 deletions browser_button.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@
<body>
<button id="get_button">Get Github Links</button>
<script src="load_links.js" charset="UTF-8"></script>
<button id="key_button">Enter Auth Key</button>
<script src="auth_key.js" charset="UTF-8"></script>
</body>
</html>
10 changes: 5 additions & 5 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ chrome.runtime.onMessage.addListener(function (message) {
const base = '/github.com/';

for (const link of links) {
const urlClean = link.href;
if (urlClean.includes(base)) array.push(urlClean);
const url = link.href;
if (url.includes(base)) array.push(url);

};

function makeTable() {
function makeList() {
let list = '<h1>Links</h1><ul>';
for (let i=0; i < array.length; i++) {
table += '<li>'+ array[i]+' <button>FORK</button></li> ';
list += '<li>'+ array[i]+' <button>FORK</button></li> ';
};
list += '</ul>'
const w = window.open("");
w.document.write(list);
}
makeTable();
makeList();
}
})

Expand Down
39 changes: 39 additions & 0 deletions gitFork.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//code to make fork post request to github api

//
const { Octokit } = require("@octokit/rest");

//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 --- please DO NOT copy/paste anywhere

const accToken = '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';
const testRepo = 'https://api.github.com/repos/CodesmithLLC/algorithms-elective';
//instantiate api
const octokit = new Octokit({
auth: accToken,
userAgent: 'auto-Fork',

timeZone: 'America/New_York',

//baseurl not required?

//debugging
log: {
debug: () => {},
info: () => {},
warn: console.warn,
error: console.error
},

request: {
agent: undefined,
fetch: undefined,
timeout: 0
}
});

//POST request to fork public repo for authenticate user. Happens asynchronously
await octokit.request('POST /repos/{owner}/{repo}/forks', {
owner: 'uitie',
repo: testRepo,
//organization optional
});
23 changes: 23 additions & 0 deletions notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
URL
------------------------------------------------------
slack github link characteristics:
<a target="_blank" class="c-link" data-stringify-link="https://github.com/CodesmithLLC/unit-11-authentication" delay="150" data-sk="tooltip_parent" href="https://github.com/CodesmithLLC/unit-11-authentication" rel="noopener noreferrer">https://github.com/CodesmithLLC/unit-11-authentication</a>

-class: c-link

urlclipping script:
const links = document.querySelectorAll("a");
const array = [];
const base = 'github';

for (const link of links) {
const urlClean = link.href;
if (urlClean.includes(base)) array.push(urlClean);

};
console.log(array);


AUTHENTICATION
------------------------------------------------------
https://docs.github.com/en/rest/guides/basics-of-authentication
3 changes: 3 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d5f0fae

Please sign in to comment.