Skip to content

Instantly share code, notes, and snippets.

@ishikawam
Created September 7, 2018 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ishikawam/52336f4bb365addc48ed73a231dcd1a3 to your computer and use it in GitHub Desktop.
Save ishikawam/52336f4bb365addc48ed73a231dcd1a3 to your computer and use it in GitHub Desktop.
LIMIAに複数の写真がある場合にヘッダに表示するJS
// ==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