Created
September 7, 2018 02:58
-
-
Save ishikawam/52336f4bb365addc48ed73a231dcd1a3 to your computer and use it in GitHub Desktop.
LIMIAに複数の写真がある場合にヘッダに表示するJS
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 characters
// ==UserScript== | |
// @name LIMIA show multiple photos | |
// @namespace M_Ishikawa | |
// @version 0.1 | |
// @description hoge | |
// @author Masayuki Ishikawa | |
// @match https://limia.jp/photo/* | |
// @grant none | |
// ==/UserScript== | |
/** | |
* for LIMIA | |
*/ | |
(function() { | |
'use strict'; | |
let idea = location.href.match(/\/([0-9]+)\//)[1]; | |
console.log(idea); | |
$.get('https://limia.jp/api/v1/photo/' + idea, {}, function(data){ | |
// console.log(data.children); | |
if (data.children.length) { | |
$('[role=main]').before("<p>写真が複数枚あります for インフルエンサーチーム</p>"); | |
} | |
$.each(data.children, function(){ | |
var imageUrl = this.photo_url.protocol + '://' + this.photo_url.host + this.photo_url.path + this.photo_url.extension; | |
console.log(imageUrl); | |
$('[role=main]').before('<a href="https://limia.jp/photo/' + this.id + '/"><img src="' + imageUrl + '" style="width: 200px; margin: 5px"></a>'); | |
}); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment