Skip to content

Instantly share code, notes, and snippets.

@mauricesvay
Created September 2, 2016 16:13
Show Gist options
  • Save mauricesvay/40c61c9e6a9f18c1e6d1240c46f2d104 to your computer and use it in GitHub Desktop.
Save mauricesvay/40c61c9e6a9f18c1e6d1240c46f2d104 to your computer and use it in GitHub Desktop.
Model tools tampermonkey script
// ==UserScript==
// @name Sketchfab Model tools
// @namespace http://svay.com/
// @version 0.1
// @description Useful tools for Sketchfab models
// @author Maurice Svay
// @match https://sketchfab.com/models/*
// @grant GM_addStyle
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
/* jshint -W097 */
'use strict';
GM_addStyle([
'.modelContainer-tools{background: #888; padding: 10px; margin-top: 10px; border-radius: 4px;}'
].join(''));
$(function(){
var $modelContainer = $('.right .navigation');
if ($modelContainer) {
var thumbnailUrl = $('meta[property="og:image"]').attr('content');
var uid = window.location.pathname.replace('/models/','');
var modelName = $('.header .model-name-label').text();
$modelContainer.prepend([
'<div class="modelContainer-tools">',
'<a class="button btn-tertiary" href="' + thumbnailUrl + '" download="' + sanitizeFilename(modelName) + '.jpg"><i class="fa fa-image"></i></a> ',
'<a class="button btn-tertiary" target="_blank" href="https://labs.sketchfab.com/experiments/gif-export/#model/' + uid + '" title="Make GIF"><i class="fa fa-video-camera"></i></a> ',
'<a class="button btn-tertiary" target="_blank" href="https://labs.sketchfab.com/experiments/screenshots/#model/' + uid + '" title="Make screenshot"><i class="fa fa-camera"></i></a> ',
'</div>'
].join(''));
}
});
function sanitizeFilename(s) {
return s.replace(/[^a-z0-9]/gi, '_').toLowerCase();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment