-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub2codesandbox.js
More file actions
23 lines (19 loc) · 862 Bytes
/
github2codesandbox.js
File metadata and controls
23 lines (19 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
javascript: (() => {
if (location.hostname !== "github.com") {
alert("Not Github");
return
}
const nowUrlArray = location.href.split("/");
let githubUrl = "";
if (nowUrlArray[5] === "tree" || nowUrlArray[5] === "blob") {
githubUrl = nowUrlArray.slice(3, 7).join("/");
} else if (nowUrlArray[5] === "pull") {
githubUrl = document.querySelector(".commit-ref.css-truncate.user-select-contain.expandable.head-ref > .no-underline")
.getAttribute("href").replace(/\//, "");
} else {
githubUrl = nowUrlArray.slice(3, 5).join("/");
}
window.open("https://codesandbox.io/s/github/" + githubUrl);
})();
//https://github.com/kagekiyo7/motocal/tree/Separate-additionalDamage3
//https://codesandbox.io/s/github/kagekiyo7/motocal/tree/Separate-additionalDamage3