The code I linked to is for inserting the recent activity module into page content. I just meant it could be a model for retrieving and inserting popular pages. The quickest thing would be to just replace all instances of "RecentActivity" in the script with "PopularPages" and then combine the resulting script with AddRailModule. However, with just a little more work, here is a stand-alone script you can use. Keep in mind that the current FD design has the page tools and recent activity modules so, on most screens, the popular pages module won't be visible until you read the bottom of the page and the rail content stops scrolling. If you don't care for one of those other modules, you can hide it with personal CSS.
/********************* this comment is 80 characters long *********************/
(function () {
/* setting strict mode and double-run prevention */
"use strict";
if (window.andrewds1021 && window.andrewds1021.append_popular_pages
&& window.andrewds1021.append_popular_pages.has_run) return;
if (!window.andrewds1021) {
window.andrewds1021 = {
append_popular_pages: {}
};
} else if (!window.andrewds1021.append_popular_pages) {
window.andrewds1021.append_popular_pages = {};
}
window.andrewds1021.append_popular_pages.has_run = true;
var config = mw.config.get([
"skin",
"wgScriptPath",
"wgUserId"
]);
if ((config.skin === "oasis") || !config.wgUserId
|| document.getElementById("recirculation-rail")) return;
if (!mw.loader.getModuleNames().filter(function (val) {
return val === "skin.fandomdesktop.rail.popularPages.css";
}).length) ;
jQuery.when(
jQuery.get(config.wgScriptPath + "/wikia.php", {
controller: "Fandom\\FandomDesktop\\Rail\\RailController",
method: "renderLazyContents",
modules: [
"Fandom\\FandomDesktop\\Rail\\PopularPagesModuleService"
]
}),
mw.loader.using([
"skin.fandomdesktop.rail.popularPages.css"
])
).then(function () {
var html_str = arguments[0][0];
var wrapper = document.getElementById("WikiaAdInContentPlaceHolder");
html_str = html_str.substring(html_str.indexOf(">") + 1,
html_str.lastIndexOf("<")).trim();
if (wrapper) {
html_str = html_str.substring(html_str.indexOf(">") + 1,
html_str.lastIndexOf("<")).trim();
} else {
wrapper = document.querySelector(".WikiaRail > .sticky-modules-wrapper");
}
if (wrapper) wrapper.insertAdjacentHTML('beforeend', html_str);
});
})();