Created
March 7, 2019 15:45
-
-
Save Tiramisu77/c7a5cffe5d59ad641a12638a788bc6bf to your computer and use it in GitHub Desktop.
lift MDN usercscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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