Sublime Forum

Building an ActiveXObject in JS

#1

I’m trying to run this piece of code to check for errors in sublime text.

Is this possible natively or with the help of an additional package?

String.prototype.getURLTitle = function() {
urlTest = new ActiveXObject('Microsoft.XMLHTTP');
try {
urlTest.open('GET', this, false);
urlTest.send();
var title = urlTest.responseText.replace(/[\S\s]*?<title>([^<]+?)<\/title>[\S\s]+/gm, '$1');
if (urlTest.status != 404) return title;
} catch(err) {return false}
}

var str = 'https://regex101.com'.getURLTitle();

console.log(str);
0 Likes

#2

Sublime can run any external program that you want via a build system, which requires that you provide a sublime-build file that tells it what command it should be executing and in what circumstances. So for the purpose of running this code to see if it works or what it does, you could do that with a combination of NodeJS and a build system.

An example of that can be found here:

0 Likes

#3

That code isn’t going to run anywhere but Microsoft Internet Explorer, because ActiveX is a proprietary “feature” not supported by any modern browser (or by Node.js).

2 Likes

#4

Thanks, the program I’m using can run the code but the editor for it is cumbersome, to say the least.

I thought there may be a way of using ST.

Thanks.

0 Likes