1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ストック数用のbookmarklet

Last updated at Posted at 2017-06-10
  • http://qiita.com/hikarut/items/c71063af8cb79124de72 のextensionが動かなかったので、bookmarkletにした
  • error logをalertにした
  • chromeなのでes6で書いてみた
    • let, const, template literal
  • 一部minifyしてある
  • stockersへのリンク追加
qiita_stock.js
javascript:(() => {
    let path = window.location.pathname
    , itemId=path.substr(-20, 20)
    , url = `https://qiita.com/api/v1/items/${itemId}`;
    if (path.match(/items/)) {
        $.ajax({
            url: url,
            success :(t) => {
                $(".StockButton__label").prepend(t.stock_count);
                const stockerLink = $(`<a href="https://qiita.com/items/${itemId}/stockers">stockers</a>`);
                $(".ArticleAsideHeader__stock").prepend(stockerLink);
            },
            error:() => {
                alert("qiitaStock request error");
            },
            dataType:"json",
            timeout:3e3}
        );
    }
})()
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?