siteinfo regexp demo
by
noromanba
2013-09-30 [2013/09/30 05:48:08]
(Forked from
siteinfo regexp demo by
taizooo)
visualize SITEINFO pattern, link to String_random.js demo page; for Autopagerize Database
@@ -31,7 +31,7 @@
})();
// PD by tombloo
-// c.f. https://github.com/to/tombloo/blob/xpi/chrome/content/library/01_utility.js#L2489
+// c.f. https://github.com/to/tombloo/blob/master/xpi/chrome/content/library/01_utility.js#L2489
var commentToText = function (commentFunc) {
return commentFunc.toString().replace(/^.*?\r?\n/, '').replace(/\r?\n.*?$/, '');
};
@@ -69,4 +69,4 @@
}, false);
});
-})(); // /anonwrap
+})(); // /anonwrap
/*
* @title siteinfo regexp demo
* @description visualize SITEINFO pattern, link to String_random.js demo page; for Autopagerize Database
* @include http://wedata.net/items/*
* @include http://wedata.net/databases/*
* @contributor taizooo http://let.hatelabo.jp/taizooo/let/hLHUotLLysV8 (Fork of)
* @orig-license Unknown (as-is)
* @contributor noromanba http://let.hatelabo.jp/noromanba/let/hJmcrJG18dRE
* @license TBD
* @require https://gist.github.com/cho45/3238/raw/dollarX.js
*/
// String_random.js
// http://lowreal.net/2013/09/13/1
// http://cho45.stfuawsc.com/String_random.js/demo.html
// c.f. http://wedata.net/databases/AutoPagerize/items
(function anonwrap() {
// c.f.
// https://userscripts.org/scripts/show/135577
// https://gist.github.com/noromanba/2897358#file-addicted-to-google-code-prettify-user-js-L111
var addStyle = (function () {
var parent = document.head || document.documentElement || document.body;
var style = document.createElement('style');
style.type = 'text/css';
parent.appendChild(style);
return function (css) {
style.appendChild(document.createTextNode(css + '\n'));
};
})();
// PD by tombloo
// c.f. https://github.com/to/tombloo/blob/master/xpi/chrome/content/library/01_utility.js#L2489
var commentToText = function (commentFunc) {
return commentFunc.toString().replace(/^.*?\r?\n/, '').replace(/\r?\n.*?$/, '');
};
// PD Icon by El T http://commons.wikimedia.org/wiki/File:Information_icon.svg
// transcode w/ http://blog.thingslabo.com/archives/000058.html
var icon = function () {/*
.let-regexp-pattern :after {
margin-left: 2px;
vertical-align: middle;
content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAACa0lEQVQ4jaWTPWhUURCFv7nz3jOb3UDirsEYf4Ib//AHLdSNCWJEgoKNjYJYCDYiaKeIaKMoSMDKWgu1shJEiASDdRoLbYIRQSIYNRs30d297913LbIb/ImVp7lwZjj3HGYG/hPyJ3Hk/LNla7s6L7a2hoczLaYLIahX45nZ2erTypupG48fH7f/FDhza7x/RXvm/qZi14ZcWwuqgjEGVaH6o87rN5OVmXL5+N3LB0f+Ejh7a7y/e1X7k9XdhbyqQY2wZU2EiPBu2tHkJibe8+3zx1PXLww+AjBN29lsdC+fb89b67DWYWPHjp6I7esifuWKxbUkYe7BpdtP2gACgO6VnZcKKzo2WutQFdSlqBqejc9hjMHGDk096gRVobe4XiZezz4H+gKAUGUIL9g4QZ0higx7N2cRARFhuhzjnG+ICy0tEc5HpcUIRnz3rzZrtYS3U1V29bays5jBpW4xRr3xxqkwNjZWCADS1Ac2dg2LHqfC1HR9cTqxdSQpqDMYFTT1uBSAXADgkuSLtW6NNorNrE3YOCVxHlWPaXwiPiaTyc4EAPOxexrV7K4oDFBdyBr8JuAWBJzHqFCbr1LIuWqpVKoYgHK5cjOpVSo2XshH6jm2v7AocLRvOT5NadY/fnjPno3htd8W6dyNl0NOlo2YMEcUGvq2d2CMYATECK8m5vEilGc+sbvn++TpE4d6/1rlK8MvTn6thw8T2iQMgoWxqaDGkLiY2vw0/Zv95LpO3TY4OFhb8piGh0eyn8WMzlVNycaC954wSOlq99V9W6OrQ4cO3PnnMf2J0dHRvKq2hWH4dWBgYG6pnp/bTxtYGeWqeAAAAABJRU5ErkJggg==);
}
*/};
addStyle(commentToText(icon));
var linkify = function (context) {
var containers = $X('//tr[th[text()="url"]]/td', context);
containers.forEach(function (container) { // TBD async/wait
var pattern = container.textContent;
var escaped = encodeURIComponent(pattern);
var demoAPI = 'http://cho45.stfuawsc.com/String_random.js/demo.html#' + escaped;
container.innerHTML = '<a href="' + demoAPI + '">' + pattern + '</a>';
container.classList.add('let-regexp-pattern'); // HTML5, alt. className +=
});
};
linkify(document.body);
[
'AutoPatchWork.DOMNodeInserted',
'AutoPagerize_DOMNodeInserted',
'AutoPagerAfterInsert'
].forEach(function (paging) {
document.body.addEventListener(paging, function (evt) {
linkify(evt.target);
}, false);
});
})(); // /anonwrap
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。