I currently have a Chrome Extention, that runs a series of jQuery at the end of the document, to replace links containing a string through the inject script. While this works on the website https://en.wikipedia.org/wiki/The_Sun_(United_Kingdom), this does not work on google.com (https://www.google.co.uk/#q=the+sun).
Inject Script
var arr = [
'twitter.com/thesun',
'facebook.com/thesun/',
'https://www.facebook.com/thesun/',
'thesun.co.uk',
'https://www.thesun.co.uk/',
'www.thesun.co.uk',
'thesun.co.uk'
];
$.each(arr, function (index, value) {
$('a[href*="'+value+'"]').each(function() {
$(this).text('ECLIPSE THE SUN');
$(this).css("color","red");
$(this).css({background:"black"});
$(this).prop("href", "http://www.contrast.org/hillsborough/");
});
});
Manifest.json
{
"name": "CHANGE THIS : Extension boilerplate",
"version": "0.0.1",
"manifest_version": 2,
"description": "This extension was created with the awesome extensionizr.com",
"homepage_url": "http://extensionizr.com",
"icons": {
"16": "icons/icon16.png",
"48": "icons/icon48.png",
"128": "icons/icon128.png"
},
"default_locale": "en",
"background": {
"page": "src/bg/background.html",
"persistent": true
},
"options_page": "src/options_custom/index.html",
"browser_action": {
"default_icon": "icons/icon19.png",
"default_title": "browser action demo",
"default_popup": "src/browser_action/browser_action.html"
},
"permissions": [
"notifications"
],
"content_scripts": [
{
"all_frames": true,
"matches": [
"<all_urls>"
],
"js": [
"js/jquery/jquery.min.js",
"src/inject/inject.js"
],
"run_at": "document_end"
}]}