500px.com View

Gets you to the real image (and more)!

  1. // ==UserScript==
  2. // @name 500px.com View
  3. // @namespace github.com/hrxn
  4. // @version 0.5
  5. // @description Gets you to the real image (and more)!
  6. // @author Hrxn <github.com/hrxn>
  7. // @license Creative Commons BY-NC-SA
  8. // @match *://500px.com/*
  9. // @grant none
  10. // @icon https://assetcdn.500px.org/assets/favicon-1e8257b93fb787f8ceb66b5522ee853c.ico
  11. // ==/UserScript==
  12. 'use strict';
  13.  
  14. var fivehundredpx = function () {
  15. var resrc = [];
  16. var rname = [];
  17. function conWrite(link, title) {
  18. console.log(link);
  19. console.log(title);
  20. }
  21. function addLinks(src, fn) {
  22. var el = document.querySelector('.main_container .sidebar_region .actions_region');
  23. el.insertAdjacentHTML('afterEnd', '<a href="' + src + '" target="_blank"> [ View... ] </a> | <a href="' + src + '" download="' + fn + '"> [ Try Download... ] </a>');
  24. }
  25. function aryreset() {
  26. resrc = [];
  27. rname = [];
  28. }
  29. function afilters(s1, s2) {
  30. s2 = s2.replace(" on 500px", "");
  31. resrc.push(s1);
  32. rname.push(s2);
  33. if (resrc.length > 1 && rname.length > 1) {
  34. var r1 = resrc[resrc.length - 1];
  35. var r2 = rname[rname.length - 1];
  36. addLinks(r1, r2);
  37. conWrite(r1, r2);
  38. aryreset();
  39. } else {
  40. var r3 = resrc[0];
  41. var r4 = rname[0];
  42. addLinks(r3, r4);
  43. conWrite(r3, r4);
  44. }
  45. }
  46. var observerHandler = function (mutations) {
  47. mutations.forEach(function (mutation) {
  48. if (mutation.type === 'attributes' && mutation.attributeName === 'src' && mutation.target.className === 'photo' && mutation.target.src.indexOf('m%3D2048') > 0) {
  49. afilters(mutation.target.src, mutation.target.alt);
  50. }
  51. });
  52. };
  53. var MutationObserver = window.MutationObserver;
  54. var target = document.querySelector('body');
  55. var observer = new MutationObserver(observerHandler);
  56. var config = {attributes: true, subtree: true};
  57. observer.observe(target, config);
  58. };
  59. fivehundredpx();