instagram_allow_saveimage2

Allow "Save image as..." on context menu of Instagram.

  1. // ==UserScript==
  2. // @name instagram_allow_saveimage2
  3. // @namespace http://catherine.v0cyc1pp.com/instagram_allow_saveimage.user2.js
  4. // @match https://www.instagram.com/*
  5. // @version 2.3
  6. // @grant none
  7. // @run-at document-end
  8. // @description Allow "Save image as..." on context menu of Instagram.
  9. // @description KNOWN ISSUE: can't save videos.
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. //console.log("instagram_allow_saveimage2 start");
  14.  
  15. function proc_mainpage(elem) {
  16. var parent = elem.parentNode;
  17. if (parent == null || parent == undefined) {
  18. return;
  19. }
  20. var next = parent.nextElementSibling;
  21. if (next == null || next == undefined) {
  22. return;
  23. }
  24.  
  25. var next2 = next.nextElementSibling;
  26. if (next2 != null || next2 != undefined) {
  27. var next2_classname = next2.className;
  28. if (next2_classname != undefined) {
  29. return;
  30. }
  31. }
  32.  
  33.  
  34. var classname = next.className;
  35.  
  36.  
  37.  
  38. var kids = next.children;
  39. if (kids.length == 0) {
  40. next.style.display = "none";
  41. } else {
  42. next.style.display = "block";
  43. }
  44. }
  45.  
  46. function proc_stories(elem) {
  47. var next = elem.nextElementSibling;
  48. if (next == null || next == undefined) {
  49. return;
  50. }
  51. var tagname = next.tagName;
  52. console.log("tagname="+tagname);
  53. if ( tagname == "DIV" ) {
  54. next.style.display = "none";
  55. }
  56. }
  57.  
  58. function main() {
  59. //$("img").each(function() {
  60. document.querySelectorAll("img").forEach(function(elem) {
  61. //$(this).removeAttr("srcset");
  62. //elem.removeAttribute("srcset");
  63. //$(this).removeAttr("sizes");
  64. //elem.removeAttribute("sizes");
  65.  
  66. // メイン用:親の次の兄弟
  67. proc_mainpage(elem);
  68.  
  69. // ストーリー用:elemの次の兄弟
  70. // →画像クリックで一時停止できなくなるのでやめた。2021.3.2
  71. //proc_stories(elem);
  72.  
  73. });
  74.  
  75. }
  76.  
  77.  
  78. var observer = new MutationObserver(function(mutations) {
  79. observer.disconnect();
  80. main();
  81. observer.observe(document, config);
  82. });
  83.  
  84. var config = {
  85. attributes: true,
  86. childList: true,
  87. characterData: false,
  88. subtree: true
  89. };
  90.  
  91. observer.observe(document, config);