Greasemonkey script for changing “inbox” to “test” at yahoo mail

ⅰ亾dé卋堺 提交于 2019-12-13 09:19:35

问题


with Greasemonkey script, I would like to change the link "inbox" to "test", it's probably in AJAX. How to do it? Ram

Update from OP remark, below:

Well i'm a newbie, could some one please write the script to change the word "inbox" to "test" on yahoo mail? (Andy's script didn't work for me)


回答1:


well greasemonkey is just javascript injected into the page.

So assuming you know how to use greasemonkey, you just need to write a short peice of code to find the link/button and manipulate its text something like (if you don't have jQuery):

document.getElementById('buttonIDName').innerHtml = 'test';
document.getElementById('buttonIDName').href = 'javascript:alert("you clicked test")';

If you did happen to have Jquery or the like available then you could do something like:

$('#buttonIDName').html('test').click(function(){alert('you clicked test');});

Greasemonkey is just another JS script, that gets run after page load.




回答2:


Update: I had only tested the script on my main Yahoo account which is on the UK domain. Of course, Yahoo uses markedly different code for different countries.

The script, below has been updated to work on the US domain and (probably/hopefully) most Yahoo editions in English.


"Well i'm a newbie, could some one please write the script to change the word "inbox" to "test" on yahoo mail?

Well, since that script took 60 seconds to write and 60 seconds to test, here it is...

/*  Save this file as "YaHellFoo.user.js".   Then open it (Ctrl-O) with Firefox and
    let Greasemonkey install it.
*/

// ==UserScript==
// @name           Dirt Simple Demo, just uses jQuery to change the "Inbox" link to "test".
// @namespace      YaHell
// @include        http://*.mail.yahoo.com/*
// @require        http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
// ==/UserScript==

if (window.top != window.self)  //don't run on frames or iframes
    return;


$(document).ready (Greasemonkey_main);


function Greasemonkey_main ()
{
    $("a:contains('Inbox')").each
    (
        function (index)
        {
            var jNode   = $(this);
            if (jNode.text()  ==  "Inbox")
                jNode.text("test")
        }
    );

    //-- Different countries' YaHell instances display Inbox with different code!
    $("span:contains('Inbox')").each
    (
        function (index)
        {
            var jNode   = $(this);
            if (jNode.text()  ==  "Inbox")
                jNode.text("test")
        }
    );
}


来源:https://stackoverflow.com/questions/3552270/greasemonkey-script-for-changing-inbox-to-test-at-yahoo-mail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!