Last active
March 31, 2023 04:17
-
-
Save FlatMapIO/aa086305fcc9155f6b71f6b793966e80 to your computer and use it in GitHub Desktop.
Revisions
-
FlatMapIO revised this gist
Mar 31, 2023 . 1 changed file with 35 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,21 +4,40 @@ // @version 1.0 // @description Add a button to replace github.com with block.githubnext.com in the URL bar on GitHub repositories page // @author https://twitter.com/stackobserve // @match https://github.com/*/* // @grant window.onurlchange // ==/UserScript== if (window.onurlchange === null) { // feature is supported window.addEventListener("urlchange", inject); } function inject({ url }) { // console.log("inject", url); const url_segments = url.split("/"); if (url_segments.length < 5) return; const container = document.querySelector("ul.pagehead-actions"); if (container === null) { return console.warn( "[GithubBlocks] query is invalid: ul.pagehead-actions is not found" ); } const [user, repo, ...paths] = url_segments.slice(3); if (paths[0] === "tree") paths[0] = "blob"; const path = paths.join("/"); const next_url = `https://blocks.githubnext.com/${user}/${repo}/${path}`; render(container, next_url); } function render(parent, url) { const newInnerHTML = `<a id='__gm_blocks' class="btn-sm btn BtnGroup-item" href="${url}">Blocks</a>`; let target = document.getElementById("__gm_blocks"); if (target === null) { const li = document.createElement("li"); li.innerHTML = newInnerHTML; parent.insertBefore(li, parent.firstChild); target = li.children.item(0); } else { target.parentElement.innerHTML = newInnerHTML; } } -
FlatMapIO revised this gist
Mar 31, 2023 . 1 changed file with 6 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ // @name Gitbub Blocks // @namespace https://github.com/ // @version 1.0 // @description Add a button to replace github.com with block.githubnext.com in the URL bar on GitHub repositories page // @author https://twitter.com/stackobserve // @match https://github.com/* // @grant none @@ -12,11 +12,13 @@ 'use strict'; const repo_url = document.location.href; const url_segments = repo_url.split('/'); if(url_segments.length < 5) return; const container = document.querySelector('ul.pagehead-actions') if(container === null) return console.warn('[GithubBlocks] query is invalid: ul.pagehead-actions is not found') const [user, repo, ...paths] = url_segments.slice(3); if(paths[0]==='tree') paths[0] = 'blob' const path = paths.join('/') const next_url = `https://blocks.githubnext.com/${user}/${repo}/${path}` const blocks_view = `<li> <a class="btn-sm btn BtnGroup-item" href="${next_url}">Blocks</a> </li>` container.innerHTML = blocks_view + container.innerHTML })(); -
FlatMapIO revised this gist
Mar 31, 2023 . No changes.There are no files selected for viewing
-
FlatMapIO revised this gist
Mar 31, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ // @namespace https://github.com/ // @version 1.0 // @description Add a button to replace github.com with blocks.githubnext.com in the URL bar on GitHub repositories page // @author https://twitter.com/stackobserve // @match https://github.com/* // @grant none // ==/UserScript== -
FlatMapIO revised this gist
Mar 31, 2023 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,8 +2,8 @@ // @name Gitbub Blocks // @namespace https://github.com/ // @version 1.0 // @description Add a button to replace github.com with blocks.githubnext.com in the URL bar on GitHub repositories page // @author @stackobserve // @match https://github.com/* // @grant none // ==/UserScript== -
FlatMapIO created this gist
Mar 31, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ // ==UserScript== // @name Gitbub Blocks // @namespace https://github.com/ // @version 1.0 // @description Add a button to replace github.com with block.githubnext.com in the URL bar on GitHub repositories page // @author Your name // @match https://github.com/* // @grant none // ==/UserScript== (function() { 'use strict'; const repo_url = document.location.href; const url_segments = repo_url.split('/'); if(url_segments.length < 4) return; const container = document.querySelector('ul.pagehead-actions') if(container === null) return console.warn('[GithubBlocks] query is invalid: ul.pagehead-actions is not found') const [user, repo, , ...paths] = url_segments.slice(3); const next_url = `https://blocks.githubnext.com/${user}/${repo}/blob/${paths.join('/')}` const blocks_view = `<li> <a class="btn-sm btn BtnGroup-item" href="${next_url}">Blocks</a> </li>` container.innerHTML = blocks_view + container.innerHTML })();