Ilian
Ilian

Reputation: 297

Chrome and Auto execute a javascript function

Is there a way to execute some javascript on load a web site. For example I want to hide facebook chat and I want to execute document.getElementById('pagelet_chat_home').style.display = "none" on loading a site.

Upvotes: 1

Views: 1208

Answers (1)

Andris
Andris

Reputation: 27885

You could wrap the needed actions into a greasmonkey script - Chrome supports greasemonkey user scripts out of the box and converts them into a plugins automatically.

Save the following as script.user.js and open it with Chrome. Chrome should detect it as a plugin and install it. Didn't check if it actually works but there shouldn't be any problems.

// ==UserScript==
// @name          Hide Pagelet
// @namespace     hide_pagelet
// @description   An example Greasemonkey script that hides a pagelet
// @include       http://*.facebook.com/*
// ==/UserScript==

document.getElementById('pagelet_chat_home').style.display = "none";

Upvotes: 4

Related Questions