From 1cbb29b02f751592d5548661e6b3230d5fafd3ca Mon Sep 17 00:00:00 2001 From: double beep <38133098+double-beep@users.noreply.github.com> Date: Mon, 14 Oct 2024 12:10:06 +0000 Subject: [PATCH] fix: remove duplicate `meta*` headers --- dist/headers.js | 19 +++++-------------- dist/legacy/index.min.user.js | 19 +++++-------------- dist/legacy/index.user.js | 19 +++++-------------- dist/modern/index.min.user.js | 19 +++++-------------- dist/modern/index.user.js | 19 +++++-------------- package-lock.json | 8 ++++---- package.json | 2 +- 7 files changed, 30 insertions(+), 75 deletions(-) diff --git a/dist/headers.js b/dist/headers.js index a87cc16..2caebe3 100644 --- a/dist/headers.js +++ b/dist/headers.js @@ -1,10 +1,10 @@ // ==UserScript== // @name Comment Image Upload +// @namespace userscripters +// @version 0.2.0 // @author Oleg Valter // @contributors double beep (https://github.com/double-beep) // @description Userscript for uploading comment images -// @grant none -// @homepage https://github.com/userscripters/comment-image-upload#readme // @license GPL-3.0-or-later // @match https://stackoverflow.com/questions/* // @match https://serverfault.com/questions/* @@ -26,18 +26,9 @@ // @match https://ru.meta.stackoverflow.com/questions/* // @match https://es.stackoverflow.com/questions/* // @match https://es.meta.stackoverflow.com/questions/* -// @match https://meta.meta.superuser.com/questions/* -// @match https://meta.meta.serverfault.com/questions/* -// @match https://meta.meta.askubuntu.com/questions/* -// @match https://meta.meta.mathoverflow.net/questions/* -// @match https://pt.meta.meta.stackoverflow.com/questions/* -// @match https://meta.meta.stackoverflow.com/questions/* -// @match https://ja.meta.meta.stackoverflow.com/questions/* -// @match https://ru.meta.meta.stackoverflow.com/questions/* -// @match https://es.meta.meta.stackoverflow.com/questions/* -// @namespace userscripters +// @grant none // @run-at document-body -// @source git+https://github.com/userscripters/comment-image-upload.git // @supportURL https://github.com/userscripters/comment-image-upload/issues -// @version 0.2.0 +// @source git+https://github.com/userscripters/comment-image-upload.git +// @homepage https://github.com/userscripters/comment-image-upload#readme // ==/UserScript== \ No newline at end of file diff --git a/dist/legacy/index.min.user.js b/dist/legacy/index.min.user.js index 0920ed8..65ab840 100644 --- a/dist/legacy/index.min.user.js +++ b/dist/legacy/index.min.user.js @@ -1,10 +1,10 @@ // ==UserScript== // @name Comment Image Upload +// @namespace userscripters +// @version 0.2.0 // @author Oleg Valter // @contributors double beep (https://github.com/double-beep) // @description Userscript for uploading comment images -// @grant none -// @homepage https://github.com/userscripters/comment-image-upload#readme // @license GPL-3.0-or-later // @match https://stackoverflow.com/questions/* // @match https://serverfault.com/questions/* @@ -26,20 +26,11 @@ // @match https://ru.meta.stackoverflow.com/questions/* // @match https://es.stackoverflow.com/questions/* // @match https://es.meta.stackoverflow.com/questions/* -// @match https://meta.meta.superuser.com/questions/* -// @match https://meta.meta.serverfault.com/questions/* -// @match https://meta.meta.askubuntu.com/questions/* -// @match https://meta.meta.mathoverflow.net/questions/* -// @match https://pt.meta.meta.stackoverflow.com/questions/* -// @match https://meta.meta.stackoverflow.com/questions/* -// @match https://ja.meta.meta.stackoverflow.com/questions/* -// @match https://ru.meta.meta.stackoverflow.com/questions/* -// @match https://es.meta.meta.stackoverflow.com/questions/* -// @namespace userscripters +// @grant none // @run-at document-body -// @source git+https://github.com/userscripters/comment-image-upload.git // @supportURL https://github.com/userscripters/comment-image-upload/issues -// @version 0.2.0 +// @source git+https://github.com/userscripters/comment-image-upload.git +// @homepage https://github.com/userscripters/comment-image-upload#readme // ==/UserScript== var __awaiter=this&&this.__awaiter||function(e,i,c,l){return new(c=c||Promise)(function(n,t){function r(e){try{o(l.next(e))}catch(e){t(e)}}function a(e){try{o(l.throw(e))}catch(e){t(e)}}function o(e){var t;e.done?n(e.value):((t=e.value)instanceof c?t:new c(function(e){e(t)})).then(r,a)}o((l=l.apply(e,i||[])).next())})},__generator=this&&this.__generator||function(r,a){var o,i,c,l={label:0,sent:function(){if(1&c[0])throw c[1];return c[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=e(0),s.throw=e(1),s.return=e(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function e(n){return function(e){var t=[n,e];if(o)throw new TypeError("Generator is already executing.");for(;l=s&&t[s=0]?0:l;)try{if(o=1,i&&(c=2&t[0]?i.return:t[0]?i.throw||((c=i.return)&&c.call(i),0):i.next)&&!(c=c.call(i,t[1])).done)return c;switch(i=0,(t=c?[2&t[0],c.value]:t)[0]){case 0:case 1:c=t;break;case 4:return l.label++,{value:t[1],done:!1};case 5:l.label++,i=t[1],t=[0];continue;case 7:t=l.ops.pop(),l.trys.pop();continue;default:if(!(c=0<(c=l.trys).length&&c[c.length-1])&&(6===t[0]||2===t[0])){l=0;continue}if(3===t[0]&&(!c||t[1]>c[0]&&t[1]=t))return e}}}}function insertText(o,i){return __awaiter(this,void 0,void 0,function(){var t,n,r,a;return __generator(this,function(e){switch(e.label){case 0:return t=i.selectionStart,r=i.selectionEnd,n="[Uploading ".concat(o.name,"...]()"),i.setRangeText(n,t,r,"start"),[4,uploadImage(o)];case 1:return r=e.sent(),a="enter image description here",i.setRangeText("[".concat(a,"](").concat(r,")"),t,t+n.length,"start"),i.setSelectionRange(t+1,t+1+a.length,"forward"),[2]}})})}function handleEvent(a){return __awaiter(this,void 0,void 0,function(){var t,n,r;return __generator(this,function(e){switch(e.label){case 0:if(!(t=a.target).matches("textarea.js-comment-text-input"))return[2];if(a.preventDefault(),!(n=findImage(a)))return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,insertText(n,t)];case 2:return e.sent(),[3,4];case 3:return r=e.sent(),console.error(r),[3,4];case 4:return[2]}})})}function appendButton(a){var e,t=this,o=document.createElement("input"),n=(o.type="file",o.addEventListener("change",function(){return __awaiter(t,void 0,void 0,function(){var t,n,r;return __generator(this,function(e){switch(e.label){case 0:if(r=null==(r=o.files)?void 0:r[0],t=a.querySelector("textarea.js-comment-text-input"),!r||!t)return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,insertText(r,t)];case 2:return e.sent(),[3,4];case 3:return n=e.sent(),console.error(n),[3,4];case 4:return[2]}})})}),document.createElement("button")),r=(n.classList.add("s-btn","s-btn__link","ta-left","px2"),n.type="button",n.innerText="Upload image",n.addEventListener("click",function(){o.click()}),a.querySelector(".js-comment-help-link"));r&&(null!=(e=r.parentElement)&&e.classList.add("g4"),r.before(n))}window.addEventListener("paste",handleEvent),window.addEventListener("drop",handleEvent),document.querySelectorAll(".js-add-link").forEach(function(t){t.addEventListener("click",function(){setTimeout(function(){var e=t.closest(".post-layout--right");e&&appendButton(e)},200)})}); \ No newline at end of file diff --git a/dist/legacy/index.user.js b/dist/legacy/index.user.js index 3ecb736..c78f52d 100644 --- a/dist/legacy/index.user.js +++ b/dist/legacy/index.user.js @@ -1,10 +1,10 @@ // ==UserScript== // @name Comment Image Upload +// @namespace userscripters +// @version 0.2.0 // @author Oleg Valter // @contributors double beep (https://github.com/double-beep) // @description Userscript for uploading comment images -// @grant none -// @homepage https://github.com/userscripters/comment-image-upload#readme // @license GPL-3.0-or-later // @match https://stackoverflow.com/questions/* // @match https://serverfault.com/questions/* @@ -26,20 +26,11 @@ // @match https://ru.meta.stackoverflow.com/questions/* // @match https://es.stackoverflow.com/questions/* // @match https://es.meta.stackoverflow.com/questions/* -// @match https://meta.meta.superuser.com/questions/* -// @match https://meta.meta.serverfault.com/questions/* -// @match https://meta.meta.askubuntu.com/questions/* -// @match https://meta.meta.mathoverflow.net/questions/* -// @match https://pt.meta.meta.stackoverflow.com/questions/* -// @match https://meta.meta.stackoverflow.com/questions/* -// @match https://ja.meta.meta.stackoverflow.com/questions/* -// @match https://ru.meta.meta.stackoverflow.com/questions/* -// @match https://es.meta.meta.stackoverflow.com/questions/* -// @namespace userscripters +// @grant none // @run-at document-body -// @source git+https://github.com/userscripters/comment-image-upload.git // @supportURL https://github.com/userscripters/comment-image-upload/issues -// @version 0.2.0 +// @source git+https://github.com/userscripters/comment-image-upload.git +// @homepage https://github.com/userscripters/comment-image-upload#readme // ==/UserScript== "use strict"; diff --git a/dist/modern/index.min.user.js b/dist/modern/index.min.user.js index 79ef333..cb8ac43 100644 --- a/dist/modern/index.min.user.js +++ b/dist/modern/index.min.user.js @@ -1,10 +1,10 @@ // ==UserScript== // @name Comment Image Upload +// @namespace userscripters +// @version 0.2.0 // @author Oleg Valter // @contributors double beep (https://github.com/double-beep) // @description Userscript for uploading comment images -// @grant none -// @homepage https://github.com/userscripters/comment-image-upload#readme // @license GPL-3.0-or-later // @match https://stackoverflow.com/questions/* // @match https://serverfault.com/questions/* @@ -26,20 +26,11 @@ // @match https://ru.meta.stackoverflow.com/questions/* // @match https://es.stackoverflow.com/questions/* // @match https://es.meta.stackoverflow.com/questions/* -// @match https://meta.meta.superuser.com/questions/* -// @match https://meta.meta.serverfault.com/questions/* -// @match https://meta.meta.askubuntu.com/questions/* -// @match https://meta.meta.mathoverflow.net/questions/* -// @match https://pt.meta.meta.stackoverflow.com/questions/* -// @match https://meta.meta.stackoverflow.com/questions/* -// @match https://ja.meta.meta.stackoverflow.com/questions/* -// @match https://ru.meta.meta.stackoverflow.com/questions/* -// @match https://es.meta.meta.stackoverflow.com/questions/* -// @namespace userscripters +// @grant none // @run-at document-body -// @source git+https://github.com/userscripters/comment-image-upload.git // @supportURL https://github.com/userscripters/comment-image-upload/issues -// @version 0.2.0 +// @source git+https://github.com/userscripters/comment-image-upload.git +// @homepage https://github.com/userscripters/comment-image-upload#readme // ==/UserScript== async function uploadImage(e){var t=new FormData,e=(t.append("file",e),t.append("fkey",StackExchange.options.user.fkey),new URL(location.origin+"/upload/image")),t=await fetch(e,{method:"POST",body:t});if(!t.ok)throw new Error(`Request to ${e.toString()} failed.`);var{Success:e,UploadedImage:a}=await t.json();if(e)return a;throw console.error(t),new Error("Failed to upload image.")}function findImage(e){e=e instanceof ClipboardEvent?e.clipboardData?.items||e.clipboardData?.files:e.dataTransfer?.items||e.dataTransfer?.files;if(e){e=[...e].find(e=>e.type.includes("image/"));if(e){e=e instanceof File?e:e.getAsFile();if(e){var t=StackExchange.settings.image.maxImageUploadSizeInBytes;if(!(e.size>=t))return e}}}}async function insertText(e,t){var a=t.selectionStart,n=`[Uploading ${e.name}...]()`,e=(t.setRangeText(n,a,t.selectionEnd,"start"),await uploadImage(e)),i="enter image description here";t.setRangeText(`[${i}](${e})`,a,a+n.length,"start"),t.setSelectionRange(a+1,a+1+i.length,"forward")}async function handleEvent(e){var t=e.target;if(t.matches("textarea.js-comment-text-input")){e.preventDefault();e=findImage(e);if(e)try{await insertText(e,t)}catch(e){console.error(e)}}}function appendButton(a){let n=document.createElement("input");n.type="file",n.addEventListener("change",async()=>{var e=n.files?.[0],t=a.querySelector("textarea.js-comment-text-input");if(e&&t)try{await insertText(e,t)}catch(e){console.error(e)}});var e=document.createElement("button"),t=(e.classList.add("s-btn","s-btn__link","ta-left","px2"),e.type="button",e.innerText="Upload image",e.addEventListener("click",()=>{n.click()}),a.querySelector(".js-comment-help-link"));t&&(t.parentElement?.classList.add("g4"),t.before(e))}window.addEventListener("paste",handleEvent),window.addEventListener("drop",handleEvent),document.querySelectorAll(".js-add-link").forEach(t=>{t.addEventListener("click",()=>{setTimeout(()=>{var e=t.closest(".post-layout--right");e&&appendButton(e)},200)})}); \ No newline at end of file diff --git a/dist/modern/index.user.js b/dist/modern/index.user.js index eb827a9..cc5781d 100644 --- a/dist/modern/index.user.js +++ b/dist/modern/index.user.js @@ -1,10 +1,10 @@ // ==UserScript== // @name Comment Image Upload +// @namespace userscripters +// @version 0.2.0 // @author Oleg Valter // @contributors double beep (https://github.com/double-beep) // @description Userscript for uploading comment images -// @grant none -// @homepage https://github.com/userscripters/comment-image-upload#readme // @license GPL-3.0-or-later // @match https://stackoverflow.com/questions/* // @match https://serverfault.com/questions/* @@ -26,20 +26,11 @@ // @match https://ru.meta.stackoverflow.com/questions/* // @match https://es.stackoverflow.com/questions/* // @match https://es.meta.stackoverflow.com/questions/* -// @match https://meta.meta.superuser.com/questions/* -// @match https://meta.meta.serverfault.com/questions/* -// @match https://meta.meta.askubuntu.com/questions/* -// @match https://meta.meta.mathoverflow.net/questions/* -// @match https://pt.meta.meta.stackoverflow.com/questions/* -// @match https://meta.meta.stackoverflow.com/questions/* -// @match https://ja.meta.meta.stackoverflow.com/questions/* -// @match https://ru.meta.meta.stackoverflow.com/questions/* -// @match https://es.meta.meta.stackoverflow.com/questions/* -// @namespace userscripters +// @grant none // @run-at document-body -// @source git+https://github.com/userscripters/comment-image-upload.git // @supportURL https://github.com/userscripters/comment-image-upload/issues -// @version 0.2.0 +// @source git+https://github.com/userscripters/comment-image-upload.git +// @homepage https://github.com/userscripters/comment-image-upload#readme // ==/UserScript== "use strict"; diff --git a/package-lock.json b/package-lock.json index db99073..8c0081b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@eslint/js": "^9.12.0", "@stylistic/eslint-plugin": "^2.9.0", "@types/tampermonkey": "^5.0.3", - "@userscripters/generate-headers": "^3.4.2", + "@userscripters/generate-headers": "^3.5.0", "@userscripters/generate-readme": "^3.0.2", "@userscripters/stackexchange-global-types": "^2.8.2", "typescript": "^5.6.3", @@ -585,9 +585,9 @@ } }, "node_modules/@userscripters/generate-headers": { - "version": "3.4.2", - "resolved": "https://registry.npmjs.org/@userscripters/generate-headers/-/generate-headers-3.4.2.tgz", - "integrity": "sha512-sKZNy9pf44x4wWBTGrwrvkEaCZ4p56ia9Qi4+TxBRPxJ2xzj/b3D0cxKof0S4RBQSgRIMv0d+fd68Lbm8EyNxg==", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/@userscripters/generate-headers/-/generate-headers-3.5.0.tgz", + "integrity": "sha512-YxkSzgqEEWFUhEOPSsGdMns2ZWfwoEuY0D+Tof9Mv/0jUmp+HZWgPKBP4MCOzWmZbk2oH1dy+uBfpUbxspCWwA==", "dev": true, "license": "GPL-3.0-or-later", "dependencies": { diff --git a/package.json b/package.json index b2f6487..342331a 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@eslint/js": "^9.12.0", "@stylistic/eslint-plugin": "^2.9.0", "@types/tampermonkey": "^5.0.3", - "@userscripters/generate-headers": "^3.4.2", + "@userscripters/generate-headers": "^3.5.0", "@userscripters/generate-readme": "^3.0.2", "@userscripters/stackexchange-global-types": "^2.8.2", "typescript": "^5.6.3",