Skip to content

Instantly share code, notes, and snippets.

@Tiramisu77
Created March 7, 2019 15:45
Show Gist options
  • Save Tiramisu77/c7a5cffe5d59ad641a12638a788bc6bf to your computer and use it in GitHub Desktop.
Save Tiramisu77/c7a5cffe5d59ad641a12638a788bc6bf to your computer and use it in GitHub Desktop.
lift MDN usercscript
// ==UserScript==
// @name lift MDN
// @description move search results from MDN to the top of the page
// @include https://www.google.com/search*
// @run-at document-end
// @grant none
// ==/UserScript==
(function() {
'use strict';
const isMDN = function(link) {
return /developer.mozilla.org/.test(link);
};
const main = function() {
const parent = document.querySelector(".srg");
const searchResults = document.querySelectorAll(".srg > .g");
searchResults.forEach(res => {
try {
const link = res.querySelector(".r > a").href;
if (isMDN(link)) {
parent.insertBefore(res, parent.firstChild);
}
} catch (e) {}
});
};
main();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment