فهرست منبع

Using execute instead of script tag insert to inject follow link code

CSP headers are tend to block script execution.
David Nabraczky-Hajos 1 سال پیش
والد
کامیت
ddbf1e0582
2فایلهای تغییر یافته به همراه7 افزوده شده و 1 حذف شده
  1. 1 1
      xwwp-follow-link.el
  2. 6 0
      xwwp.el

+ 1 - 1
xwwp-follow-link.el

@@ -240,7 +240,7 @@ LINKS maps a numerical ID to an array of form [link-text, link-uri]"
   (setq xwwp-follow-link-completion-backend-instance (funcall (xwwp-follow-link-make-backend)))
   (let ((xwidget (or xwidget (xwidget-webkit-current-session))))
     (xwwp-html-inject-style xwidget "__xwidget_plus_follow_link_style" (xwwp-follow-link-style-definition))
-    (xwwp-js-inject xwidget 'follow-link)
+    (xwwp-js-execute xwidget 'follow-link)
     (xwwp-follow-link-fetch-links xwidget #'xwwp-follow-link-callback)))
 
 ;; Local Variables:

+ 6 - 0
xwwp.el

@@ -143,6 +143,12 @@ and a Lisp function to call it."
          (script (mapconcat #'cdr (cdr namespace) "\n")))
     (xwwp-html-inject-script xwidget (format "--xwwp-%s" (symbol-name ns-name)) script)))
 
+(defun xwwp-js-execute (xwidget ns-name)
+  "Inject the functions defined in NS-NAME into XWIDGET session."
+  (let* ((namespace (assoc ns-name xwwp-js-scripts))
+         (script (mapconcat #'cdr (cdr namespace) "\n")))
+    (xwidget-webkit-execute-script xwidget script)))
+
 ;;;###autoload
 (defun xwwp-browse-url-other-window (url &optional new-session)
   "Ask xwidget-webkit to browse URL.