PregChan Download Button

Adds a button to image posts to download the image with it's original filename.

  1. // ==UserScript==
  2. // @name PregChan Download Button
  3. // @namespace https://twitter.com/goawaynowgan
  4. // @version 1.2
  5. // @description Adds a button to image posts to download the image with it's original filename.
  6. // @author GanBat
  7. // @include https://pregchan.com/*
  8. // @include http://pregchan.com/*
  9. // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
  10. // @grant none
  11. // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH4wIaEjM3ShSQNgAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAOFSURBVGje7Zp/SJVXGMc/51Wudn316prVqP0GxbwYWc3Jqm0yphEZRbOgwf6K3ASj3AaDQa5/gzbaXUVCjf1g7I79YK4hhqQhajcKLGW6cIuJk7JM7y+9V+rsD03YvMv33ntevS/c75/v+/Kc7/ec5zzP93BeASAH3UsIP9iCFLUI1oOwA4LEggQmgSvI+y5CKedEYZVfyL8b7QSDRxDiHWAJ1kAYHnyJd+LdVCYCFQjtbQuRB7CBthc9o01DiFrAjvWQjib3ayA2YF0UpyLVpc747Xt0ffwNXndrxPdZu1+l9OAesnJzFI0o0jWV1ab/vOd/yQN4v71A//nLKldAaCqjTfmD85cPX0BpDmlYHEkBSQFJAUkBi4vUOZ5VSvN9cYxjCCHmFxDpI9VQOUZyDyTcHngUAmM++po9hLyR/czdrt55Y9zt6qUjJSXiuzSHTsHrL2B36OYI6Gu+xB8fnI5rxkIXrzF08doj9gcU7yozJ4Uee26l6SkR7RhRCXh2fQGrT9SZRj7/+AGeKc43dxMXlpeYIiL/+AGKtr60MFVItQij5CM1wJjLqCoR0cx8pAYYVx+IV0SsaaO0kcUqQgV5ZZ04WhGqyCu1EkZFqCSv3AsVlpew+mTdgpEHEHLAPac2jdwcpsfdQnjMZyiIzaFTUr1j1sP0NHXxW82xf31T4DqIc0spAMFxP5dO/Uh43G8sfnYmzt2vkfv0CmNeyHP0a4JNnqhmonX4Dq98tA+7Q8dZ8SJ8dmhWxH/Jtx5uINDYGVV8z+Attn5aZ2wFvnu+KqblzNhWOisCYPj3vwB4Iu+puMg/xBsD7vjc6Lx2u7GTVuDl+n1kZOuzxKetuJ+2+tjJK7HTRkW03PPhrNnF0pmcvXNzmN4T3xNq71ncA41hz9/ewxUTyCbkkVLk2A09SzgBYrmDsjYXOz1nyPukFoDMnZvY1v05le2nebx6e2IL0DetYemqZWiaxpMzh5gVG9eQrtuxpdtYWeo0107HC9+5TgavDxD0BrjRMn1rM/hLO6NDI3hHxvjz147YO/HPbx0xpWLEg7TNRVSe/TDiCswRUPz+m6RtdCYU+XXv7Y14SBNywB3AmvfEgJzQgKtYFYJuDXnfBYSsN/lyCkmDhl1vREoXMGEh+mGE/AIt+IMAkDe+ygLbdjS5H8Rapn/8SLzfbQSTILuRNDApfhKFVaP/ANE1OUsaW1/TAAAAAElFTkSuQmCC
  12. // ==/UserScript==
  13.  
  14. // This script and its icon use FontAwesome icons, licensed under Creative Commons Attribution 4.0 International.
  15. // https://fontawesome.com/license
  16. // The only change made to the icon is color.
  17.  
  18. (function() {
  19. 'use strict';
  20. var $ = window.jQuery;
  21. $("head").append ('<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/solid.css" integrity="sha384-r/k8YTFqmlOaqRkZuSiE9trsrDXkh07mRaoGBMoDcmA58OHILZPsk29i2BsFng1B" crossorigin="anonymous">');
  22. $("head").append ('<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/fontawesome.css" integrity="sha384-4aon80D8rXCGx9ayDt85LbyUHeMWd3UiBaWliBlJ53yzm9hqN21A+o1pqoyK04h+" crossorigin="anonymous">');
  23.  
  24. $('.fileinfo').each(function() {
  25. var $dlsrc = $(this).children("a").first();
  26. var fnorig
  27. if ( $(this).find("span.postfilename").attr('title') == undefined ) {
  28. fnorig = $(this).find("span.postfilename").html();
  29. } else {
  30. fnorig = $(this).find("span.postfilename").attr('title');
  31. }
  32. $dlsrc.after(' <a href="'+ $dlsrc.attr('href') +'" download="'+ fnorig +'"><i class="fas fa-download"></i></a>');
  33. });
  34.  
  35. })();