Last active
January 10, 2020 16:55
-
-
Save Fprince333/bed6741ab0a6fe8f7591eedcff53d673 to your computer and use it in GitHub Desktop.
Inject this script to local market sites and deep link via the URL query parameter "country" e.g. https://www.mars.com/admin/content/acquia-contenthub?country=africa or https://www.mars.com/admin/content/acquia-contenthub?country=hong-kong
This file contains hidden or 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
| function getParameterByName(name, url) { | |
| if (!url) url = window.location.href; | |
| name = name.replace(/[\[\]]/g, '\\$&'); | |
| var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), | |
| results = regex.exec(url); | |
| if (!results) return null; | |
| if (!results[2]) return ''; | |
| return decodeURIComponent(results[2].replace(/\+/g, ' ')); | |
| } | |
| function prettify(str) { | |
| return str.split('-').map(function capitalize(part) { | |
| return part.charAt(0).toUpperCase() + part.slice(1); | |
| }).join(' '); | |
| } | |
| var country = prettify(getParameterByName('country')); | |
| var iframe = document.querySelectorAll("iframe")[0]; | |
| var tagToggle = iframe.contentWindow.$(".ch__cmp__content-search__criteria__tag"); | |
| tagToggle.find("ul").find(`label:contains('${country}')`).click(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment