Removes Google web search from exception page
[lhc/web/wiklou.git] / resources / src / mediawiki / ForeignApi.js
index 899daa5..1a3cdd5 100644 (file)
@@ -35,6 +35,9 @@
         * @constructor
         * @param {string|mw.Uri} url URL pointing to another wiki's `api.php` endpoint.
         * @param {Object} [options] See mw.Api.
+        * @param {Object} [options.anonymous=false] Perform all requests anonymously. Use this option if
+        *     the target wiki may otherwise not accept cross-origin requests, or if you don't need to
+        *     perform write actions or read restricted information and want to avoid the overhead.
         *
         * @author Bartosz DziewoƄski
         * @author Jon Robson
                }
 
                this.apiUrl = String( url );
+               this.anonymous = options && options.anonymous;
 
-               options = $.extend( /*deep=*/ true,
+               options = $.extend( /* deep=*/ true,
                        {
                                ajax: {
                                        url: this.apiUrl,
                                        xhrFields: {
-                                               withCredentials: true
+                                               withCredentials: !this.anonymous
                                        }
                                },
                                parameters: {
         * @return {string}
         */
        CoreForeignApi.prototype.getOrigin = function () {
-               var origin = location.protocol + '//' + location.hostname;
+               var origin;
+               if ( this.anonymous ) {
+                       return '*';
+               }
+               origin = location.protocol + '//' + location.hostname;
                if ( location.port ) {
                        origin += ':' + location.port;
                }