branch: elpa/fedi
commit 088c955f4982c936fb91ce108b0829bdc5abef7e
Author: marty hiatt <martianhiatus [a t] riseup [d o t] net>
Commit: marty hiatt <martianhiatus [a t] riseup [d o t] net>

    add user-agent strings
---
 fedi-http.el | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/fedi-http.el b/fedi-http.el
index 8f89498076c..780c6b20f29 100644
--- a/fedi-http.el
+++ b/fedi-http.el
@@ -53,6 +53,24 @@
 (defconst fedi-http--timeout 15
   "HTTP request timeout, in seconds.  Has no effect on Emacs < 26.1.")
 
+;; via https://github.com/SqrtMinusOne/reverso.el, thanks Korytov Pavel!
+;; to set a user-agent var for your package:
+;; (defvar lem-user-agent
+;;   (nth (random (length fedi-user-agents))
+;;        fedi-user-agents)
+;;   "User-Agent to use for requests.")
+(defconst fedi-user-agents
+  '("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like 
Gecko) Chrome/104.0.0.0 Safari/537.36"
+    "Mozilla/5.0 (X11; Linux x86_64; rv:103.0) Gecko/20100101 Firefox/103.0"
+    "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 
Firefox/103.0"
+    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 
(KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
+    "Mozilla/5.0 (Windows NT 10.0; rv:103.0) Gecko/20100101 Firefox/103.0"
+    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like 
Gecko) Chrome/103.0.0.0 Safari/537.36"
+    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 
(KHTML, like Gecko) Version/15.6 Safari/605.1.15"
+    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:103.0) Gecko/20100101 
Firefox/103.0")
+  "User-Agents to use for reverso.el requests.
+A random one is picked at package initialization.")
+
 (defun fedi-http--api (endpoint &optional url ver-str)
   "Return Fedi API URL for ENDPOINT."
   (concat (or url fedi-instance-url) "/api/"

Reply via email to