diff --git a/extension.json b/extension.json index da76362..e8f65f3 100644 --- a/extension.json +++ b/extension.json @@ -10,6 +10,9 @@ "descriptionmsg": "cookiewarning-desc", "type": "other", "license-name": "MIT", + "requires": { + "MediaWiki": ">= 1.25.0" + }, "MessagesDirs": { "CookieWarning": [ "i18n" @@ -81,6 +84,7 @@ "ext.CookieWarning": { "dependencies": [ "mediawiki.api", + "mediawiki.api.options", "mediawiki.cookie", "mediawiki.user" ], diff --git a/resources/ext.CookieWarning/ext.CookieWarning.js b/resources/ext.CookieWarning/ext.CookieWarning.js index c30b14a..8189db0 100644 --- a/resources/ext.CookieWarning/ext.CookieWarning.js +++ b/resources/ext.CookieWarning/ext.CookieWarning.js @@ -14,14 +14,12 @@ // the user preferences. if ( !mw.user.isAnon() ) { // try to save, that the cookiewarning was disabled, in the user preferences - new mw.Api().postWithToken( 'options', { - action: 'options', - change: 'cookiewarning_dismissed=1' - } ).fail( function ( code, result ) { - // if it fails, fall back to the cookie - mw.log.warn( 'Failed to save dismissed CookieWarning: ' + code + '\n' + result.error + '. Using cookie now.' ); - setCookie(); - } ); + new mw.Api().saveOption( 'cookiewarning_dismissed', '1' ) + .fail( function ( code, result ) { + // if it fails, fall back to the cookie + mw.log.warn( 'Failed to save dismissed CookieWarning: ' + code + '\n' + result.error + '. Using cookie now.' ); + setCookie(); + } ); } else { // use cookies for anonymous users setCookie();