Last active
September 30, 2015 03:17
-
-
Save XP1/1712432 to your computer and use it in GitHub Desktop.
Fix MediaWiki: Fixes MediaWiki's WikiEditor search-and-replace extension by handling the correct line endings. Allows the search-and-replace dialog to load by disabling browser version sniffing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Fix MediaWiki | |
// @version 1.02 | |
// @description Fixes MediaWiki's WikiEditor search-and-replace extension by handling the correct line endings. Allows the search-and-replace dialog to load by disabling browser version sniffing. | |
// @namespace https://gist.github.com/XP1/1712432/ | |
// @copyright 2012 | |
// @author XP1 | |
// @homepage https://github.com/XP1/ | |
// @license Apache License, Version 2.0; http://www.apache.org/licenses/LICENSE-2.0 | |
// Wikipedia: | |
// @include http*://wikipedia.org/*&action=* | |
// @include http*://*.wikipedia.org/*&action=* | |
// @include http*://wikimedia.org/*&action=* | |
// @include http*://*.wikimedia.org/*&action=* | |
// @include http*://wikibooks.org/*&action=* | |
// @include http*://*.wikibooks.org/*&action=* | |
// @include http*://wikinews.org/*&action=* | |
// @include http*://*.wikinews.org/*&action=* | |
// @include http*://wikiquote.org/*&action=* | |
// @include http*://*.wikiquote.org/*&action=* | |
// @include http*://wikisource.org/*&action=* | |
// @include http*://*.wikisource.org/*&action=* | |
// @include http*://wikiversity.org/*&action=* | |
// @include http*://*.wikiversity.org/*&action=* | |
// @include http*://mediawiki.org/*&action=* | |
// @include http*://*.mediawiki.org/*&action=* | |
// @include http*://wiktionary.org/*&action=* | |
// @include http*://*.wiktionary.org/*&action=* | |
// ==/UserScript== | |
/* | |
* Copyright 2012 XP1 | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and | |
* limitations under the License. | |
*/ | |
/*jslint browser: true, vars: true, maxerr: 50, indent: 4 */ | |
(function (window, Object) { | |
"use strict"; | |
function getTrue() { | |
return true; | |
} | |
/** | |
* Overrides jQuery to retain line endings for the current user agent. | |
* @param $ | |
* @see http://api.jquery.com/val/ | |
*/ | |
function overrideTextarea($) { | |
$.valHooks.textarea = { | |
get: function getTextareaValue(element) { | |
return element.value; | |
} | |
}; | |
} | |
function overrideWikiEditor($) { | |
var wikiEditor = null; | |
Object.defineProperty($, "wikiEditor", { | |
get: function getWikiEditor() { | |
return wikiEditor; | |
}, | |
set: function setWikiEditor(object) { | |
wikiEditor = object; | |
wikiEditor.isSupported = getTrue; | |
}, | |
enumerable: true, | |
configurable: true | |
}); | |
} | |
function overrideJquery() { | |
var $ = null; | |
Object.defineProperty(window, "$", { | |
get: function get$() { | |
return $; | |
}, | |
set: function set$(object) { | |
$ = object; | |
overrideTextarea($); | |
overrideWikiEditor($); | |
}, | |
enumerable: true, | |
configurable: true | |
}); | |
} | |
overrideJquery(); | |
}(this, this.Object)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I posted this user JS in this thread:
When editing a Wikipedia page, "search and replace" functionality is malfunctioning with Opera.:
http://my.opera.com/community/forums/topic.dml?id=1051742