Gets you to the real image!
目前為
// ==UserScript==
// @name 500px.com Userscript Experiment
// @namespace github.com/hrxn
// @description Gets you to the real image!
// @version 0.2
// @author Hrxn <github.com/hrxn>
// @license Creative Commons BY-NC-SA
// @include http*://500px.com/*
// @grant none
// @icon https://assetcdn.500px.org/assets/favicon-1e8257b93fb787f8ceb66b5522ee853c.ico
// ==/UserScript==
(function ()
{
var path = window.location.pathname.split("/");
var name = path[3];
var addElements = function (src)
{
var el = document.querySelector('.main_container .sidebar_region .photo_sidebar .actions_region');
el.insertAdjacentHTML('afterEnd', '<a href="' + src + '" target="_blank"> [ View... ] </a> | <a href="' + src + '" download="' + name + '"> [ Download... ] </a>');
}
var eventHandler = function (events)
{
events.forEach(function (event)
{
if (event.type == "attributes" && event.attributeName == 'src')
{
if (event.target.src.indexOf('/h%3D300/') == - 1 && event.target.alt != "" && event.target.className == "photo")
{
addElements(event.target.src);
// < Console debug output :
// statements go here, e.g. :
// console.log(event.target, event.target.src);
// console.log(window.location.pathname.split("/"));
// console.log(name);
// Console debug output >
}
}
});
}
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
var target = document.querySelector('body');
var observer = new MutationObserver(eventHandler);
var config =
{
attributes : true,
subtree : true
}
observer.observe(target, config);
})();