Page2LinkMD

    @@ -32,6 +32,6 @@ __link_title = __link_title.replace(/[\[\]]/g,"\\$&").replace(/\\$/, ""); -prompt("Press Ctrl/Cmd + v to copy markdown", "[" + __link_title + "](" + __location_href_url + ")"); +void prompt("Press Ctrl/Cmd + v to copy markdown", "[" + __link_title + "](" + __location_href_url + ")"); });
  • /*
     * @title Page2LinkMD
     * @description Generates current active page to markdown link format. Makes guthub repo_top/issue/pr links to a formatted title
     * @include http://*
     * @license MIT License
     * @require 
     */
    
    (function(){
    var __githubRegexp = /^https?:\/\/github.com.*/g;
    var __githubRepoRegexp = /^https?:\/\/github.com\/([^\/]+)\/([^\/]+)\/?$/g;
    var __githubIssueRegexp = /^https?:\/\/github.com\/([^\/]+)\/([^\/]+)\/issues\/(\d+)/g;
    var __githubPullRegexp = /^https?:\/\/github.com\/([^\/]+)\/([^\/]+)\/pull\/(\d+)/g;
    var __githubTitleXPath = '//*[@id="partial-discussion-header"]/div[1]/h1/span[1]';
    
    var __location_href_url = location.href;
    var __link_title = "";
    
    if (__githubRegexp.test(__location_href_url)){
      if (__githubRepoRegexp.test(__location_href_url)) {
        __link_title = __location_href_url.replace(__githubRepoRegexp, "$1/$2");
      } else if (__githubIssueRegexp.test(__location_href_url)) {
        __link_title = "Issue#" + __location_href_url.replace(__githubIssueRegexp, "$3") + " " + document.evaluate(__githubTitleXPath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
      } else if (__githubPullRegexp.test(__location_href_url)) {
        __link_title = "PR#" + __location_href_url.replace(__githubPullRegexp, "$3") + " " + document.evaluate(__githubTitleXPath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
      } else {
        __link_title = document.title;
      }
    } else {
      __link_title = document.title;
    }
    
    __link_title = __link_title.replace(/[\[\]]/g,"\\$&").replace(/\\$/, "");
    
    void prompt("Press Ctrl/Cmd + v to copy markdown", "[" + __link_title + "](" + __location_href_url + ")");
    
    });
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2017/05/08 17:53:07 - 2017-05-08
  2. 2017/05/08 17:45:34 - 2017-05-08
  3. 2017/05/08 17:45:12 - 2017-05-08
  4. 2017/05/08 17:42:43 - 2017-05-08
  5. 2017/05/08 17:41:43 - 2017-05-08
  6. 2017/05/08 17:36:52 - 2017-05-08
  7. 2017/05/08 17:05:26 - 2017-05-08
  8. 2017/05/08 17:00:14 - 2017-05-08
  9. 2017/05/08 16:58:06 - 2017-05-08