critical security update
Browse filesSigned-off-by: Balazs Horvath <[email protected]>
README.md
CHANGED
@@ -193,50 +193,58 @@ This method requires a browser extension like [ViolentMonkey](https://violentmon
|
|
193 |
|
194 |
```js
|
195 |
// ==UserScript==
|
196 |
-
// @name
|
197 |
-
// @namespace
|
198 |
-
// @version
|
199 |
-
// @description
|
200 |
-
// @author
|
201 |
-
// @match
|
202 |
-
// @match
|
203 |
-
// @grant
|
204 |
// ==/UserScript==
|
205 |
|
206 |
(function() {
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
}
|
|
|
220 |
|
221 |
-
|
222 |
-
|
223 |
-
var jsonButton = document.createElement('a');
|
224 |
-
// Set the attributes for the button
|
225 |
-
jsonButton.setAttribute('class', 'button btn-info');
|
226 |
-
var jsonUrl = constructJSONUrl();
|
227 |
-
// Set the JSON URL as the button's href attribute
|
228 |
-
jsonButton.setAttribute('href', jsonUrl);
|
229 |
-
// Set the inner HTML for the button
|
230 |
-
jsonButton.innerHTML = '<i class="fa-solid fa-angle-double-right"></i><span>JSON</span>';
|
231 |
-
|
232 |
-
// Find the container where we want to insert the button
|
233 |
-
var container = document.getElementById('image-extra-controls');
|
234 |
-
// Insert the button after the download button
|
235 |
-
container.insertBefore(jsonButton, container.children[0].nextSibling);
|
236 |
-
}
|
237 |
-
|
238 |
-
// Run the function to create the JSON button
|
239 |
-
createJSONButton();
|
240 |
})();
|
241 |
```
|
242 |
|
|
|
193 |
|
194 |
```js
|
195 |
// ==UserScript==
|
196 |
+
// @name e621 JSON Button
|
197 |
+
// @namespace https://cringe.live
|
198 |
+
// @version 1.0
|
199 |
+
// @description Adds a JSON button next to the download button on e621.net
|
200 |
+
// @author _ka_de
|
201 |
+
// @match https://e621.net/*
|
202 |
+
// @match https://e6ai.net/*
|
203 |
+
// @grant none
|
204 |
// ==/UserScript==
|
205 |
|
206 |
(function() {
|
207 |
+
'use strict';
|
208 |
+
|
209 |
+
function constructJSONUrl() {
|
210 |
+
// Get the current URL
|
211 |
+
var currentUrl = window.location.href;
|
212 |
+
// Extract the post ID from the URL
|
213 |
+
var postId = currentUrl.match(/^https?:\/\/(?:e621\.net|e6ai\.net)\/posts\/(\d+)/)[1];
|
214 |
+
// Check the hostname
|
215 |
+
var hostname = window.location.hostname;
|
216 |
+
// Construct the JSON URL based on the hostname
|
217 |
+
var jsonUrl = 'https://' + hostname + '/posts/' + postId + '.json';
|
218 |
+
return jsonUrl;
|
219 |
+
}
|
220 |
+
|
221 |
+
function createJSONButton() {
|
222 |
+
// Create a new button element
|
223 |
+
var jsonButton = document.createElement('a');
|
224 |
+
// Set the attributes for the button
|
225 |
+
jsonButton.setAttribute('class', 'button btn-info');
|
226 |
+
var jsonUrl = constructJSONUrl();
|
227 |
+
// Set the JSON URL as the button's href attribute
|
228 |
+
jsonButton.setAttribute('href', jsonUrl);
|
229 |
+
// Set the inner HTML for the button
|
230 |
+
jsonButton.innerHTML = '<i class="fa-solid fa-angle-double-right"></i><span>JSON</span>';
|
231 |
+
|
232 |
+
// Find the container where we want to insert the button
|
233 |
+
var container = document.querySelector('#post-options > li:last-child');
|
234 |
+
|
235 |
+
// Check if the #image-extra-controls element exists
|
236 |
+
if (document.getElementById('image-extra-controls')) {
|
237 |
+
// Insert the button after the download button
|
238 |
+
container = document.getElementById('image-download-link');
|
239 |
+
container.insertBefore(jsonButton, container.children[0].nextSibling);
|
240 |
+
} else {
|
241 |
+
// Insert the button after the last li element in #post-options
|
242 |
+
container.parentNode.insertBefore(jsonButton, container.nextSibling);
|
243 |
}
|
244 |
+
}
|
245 |
|
246 |
+
// Run the function to create the JSON button
|
247 |
+
createJSONButton();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
})();
|
249 |
```
|
250 |
|