Frederick888 / pawoo-twitter-preview

Preview Twitter images in Pawoo.net
GNU General Public License v3.0
0 stars 0 forks source link

`GM_xmlhttpRequest` for GM_* API casing #1

Closed Martii closed 5 years ago

Martii commented 5 years ago

Seems like you have a casing typo here a few times:

--- /scripts/Frederick888/Pawoo_Twitter_Preview/source@0.2.0+3007a08
+++ /scripts/Frederick888/Pawoo_Twitter_Preview/source
@@ -12,7 +12,7 @@
 // @updateURL       https://openuserjs.org/meta/Frederick888/Pawoo_Twitter_Preview.meta.js
 // @match           https://pawoo.net/*
 // @grant           GM.xmlHttpRequest
-// @grant           GM_xmlHttpRequest
+// @grant           GM_xmlhttpRequest
 // ==/UserScript==

 let galleryTemplate = `
@@ -34,10 +34,10 @@

 function fetchTwitterPreviewImage(twitterLink) {
     let twitterUrl = twitterLink.getAttribute('href');
-    if (typeof (GM_xmlHttpRequest) === 'undefined' && typeof (GM.xmlHttpRequest) === 'function') {
-        GM_xmlHttpRequest = GM.xmlHttpRequest;
+    if (typeof (GM_xmlhttpRequest) === 'undefined' && typeof (GM.xmlHttpRequest) === 'function') {
+        GM_xmlhttpRequest = GM.xmlHttpRequest;
     }
-    GM_xmlHttpRequest({
+    GM_xmlhttpRequest({
         method: 'GET',
         url: twitterUrl,
         headers: {
@@ -55,7 +55,7 @@
                 // console.log(openGraphImage.getAttribute('content'));
                 mediaGallery.querySelector('a.media-gallery__item-thumbnail').setAttribute('href', twitterUrl);
                 let container = twitterLink.closest('.status__content');
-                GM_xmlHttpRequest({
+                GM_xmlhttpRequest({
                     method: 'GET',
                     url: openGraphImage.getAttribute('content'),
                     headers: {

Refs:

See also https://openuserjs.org/scripts/Frederick888/Pawoo_Twitter_Preview/issues/%60GM_xmlhttpRequest%60_for_GM__API_casing . Apologies missed the @supportURL so mirrored here and closed over there. Non-OUJS-critical so I can do it here. :)

Frederick888 commented 5 years ago

Thanks for spotting this issue! I've just applied your patch and released a new version.

I actually did quickly test it in Tampermonkey and it was working all right... Maybe they've already provided some sort of alias in the extension itself...?

Martii commented 5 years ago

Welcome. Thanks for supporting the original API. :)

Maybe they've already provided some sort of alias in the extension itself...?

Refs:

... spotting this issue

Now that JSHint is configured a bit more in Ace on OUJS it showed me a warning triangle while viewing and I was like "Wha?? Just fixed this!" and then noticed the casing. :smile_cat: