Skip to content

Instantly share code, notes, and snippets.

@XP1
Created February 9, 2012 11:11
Show Gist options
  • Save XP1/1779333 to your computer and use it in GitHub Desktop.
Save XP1/1779333 to your computer and use it in GitHub Desktop.
Fix MODX: Fixes iframes in MODX to observe strict, cross-domain, same-origin policy restrictions.
// ==UserScript==
// @name Fix MODX
// @version 1.00
// @description Fixes iframes in MODX to observe strict, cross-domain, same-origin policy restrictions.
// @author XP1 (https://github.com/XP1/)
// @namespace https://gist.github.com/1779333/
// @include http*://demo.opensourcecms.com/modx/*
// @include http*://*.demo.opensourcecms.com/modx/*
// ==/UserScript==
/**
* Demo:
* http://www.opensourcecms.com/scripts/details.php?scriptid=48
*/
/*jslint browser: true, vars: true, white: true, maxerr: 50, indent: 4 */
(function (console)
{
"use strict";
var userScript =
{
name: "Fix MODX"
};
function removeEventListenerAfterFiring(numberOfTimes, callback)
{
var remaining = numberOfTimes;
return function listener(event)
{
remaining -= 1;
if (remaining <= 0)
{
var target = event.target;
var type = event.type;
target.removeEventListener(type, listener, false);
target.removeEventListener(type, listener, true);
}
callback();
};
}
var handleException = function handleException(theFunction)
{
try
{
theFunction();
}
catch (exception)
{
console.error("[" + userScript.name + "]: Exception: " + exception + "\n\nStack:\n" + exception.stack + "\n\nStacktrace:\n" + exception.stacktrace);
}
};
function fixUri()
{
var Ext = window.Ext;
var SSL_SECURE_URL = Ext.SSL_SECURE_URL.toLowerCase();
var uri = window.location.href.toLowerCase();
if (SSL_SECURE_URL === "about:blank")
{
var index = uri.indexOf("/manager");
Ext.SSL_SECURE_URL = (index !== -1 ? (uri.substring(0, index) + "/connectors/resource/index.php") : uri); // http://demo.opensourcecms.com/modx/connectors/resource/index.php
}
}
function initialize()
{
var functions = [fixUri];
var i = null;
var length = functions.length;
for (i = 0; i < length; i += 1)
{
handleException(functions[i]);
}
}
window.addEventListener("DOMContentLoaded", removeEventListenerAfterFiring(1, initialize), false);
}(window.console));
@XP1
Copy link
Author

XP1 commented Feb 9, 2012

I posted this user JS in these threads:

11.61 and modx revolution: infinite save loop; json error:
http://my.opera.com/community/forums/topic.dml?id=1287402

2.2.0 pl2 / opera 11.60: cannot change Home resource:
http://forums.modx.com/thread/73546/2-2-0-pl2-opera-11-60-cannot-change-home-resource/


Bug reports:

MODX bug #4110: Opera 11.01 Saving-Message loops endless:
http://tracker.modx.com/issues/4110/

TinyMCE issue #27: "Saving..." not disappearing in Opera:
splittingred/TinyMCE#27

TinyMCE issue #32: endless saving under 2.0.5pl with TinyMCE:
splittingred/TinyMCE#32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment