简体   繁体   English

如何在某人的网页上添加自己的图层?

[英]How can I add my own layer on someones webpage?

I would like to show a concept to my friends, using someones else webpage. 我想向其他朋友展示一个概念,使用其他人的网页。 How can I add my own layer over someones webpage? 如何在某人的网页上添加自己的图层? Greasemonkey would work? Greasemonkey会起作用吗?

You can do so with greasemonkey. 你可以用greasemonkey这样做。 You would have to create one more more div s with the correct z-index , and either position:fixed or position:absolute . 您将不得不使用正确的z-index创建一个或多个div ,并且position:fixedposition:absolute

Yes, Greasemonkey can do this by adding (or deleting, or changing) page DOM elements. 是的,Greasemonkey可以通过添加(或删除或更改)页面DOM元素来实现此目的。

Here is a starter script that "adds a layer" to Stack Overflow pages: 这是一个“添加图层”到Stack Overflow页面的入门脚本:

// ==UserScript==
// @name        _Add a "layer" to a webpage
// @namespace   Stack Overflow
// @include     http://stackoverflow.com/*
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// ==/UserScript==

$("body").prepend (
      '<div id="gmLayerWrapper">'
    + '<p>All your overflow are belong to us.<br>'
    +   '<img src="http://2.bp.blogspot.com/-hEJb82Ni7V8/TrnNc8Ljj3I/AAAAAAAABG4/Ow2GnJyDo74/s400/UnicornRainbow.jpg"'
    +   ' alt="They\'re everywhere!">'
    + '</p>'
    + '<div id="gmTransparentFilm"></div>'
    + '</div>'
);
$("#gmLayerWrapper").width  ( $(window).width  () )
                    .height ( $(window).height () )
                    ;
//--- Fudge our text width for aesthetics.
$("#gmLayerWrapper p").width  ( $(window).width () / 2 )

GM_addStyle ( (<><![CDATA[
    #gmLayerWrapper {
        margin:                 0;
        padding:                0;
        position:               fixed;
        top:                    0;
        left:                   0;
        min-width:              200px;
    }
    #gmTransparentFilm {
        margin:                 0;
        padding:                0;
        background:             red;
        opacity:                0.7;
        height:                 100%;
        width:                  100%;
        position:               absolute;
        top:                    0;
        left:                   0;
        z-index:                666;
    }
    #gmLayerWrapper p {
        padding:                0.5em 1.5em;
        margin:                 1em auto;
        background:             white;
        border-radius:          2em;
        font-size:              30px;
        line-height:            2.5;
        text-align:             center;
        vertical-align:         middle;
        min-width:              4em;
        position:               relative; /*Required for z-index*/
        z-index:                888;
    }
]]></>).toString () );


It uses: 它用:

to accomplish this. 实现这一目标。

Probably the easiest way is to File -> Save As their work and edit the resulting files. 可能最简单的方法是File -> Save As他们的工作并编辑生成的文件。 You could create a GreaseMonkey script to do so dynamically, but it sounds like a lot of work for a quick hi-5. 您可以创建一个GreaseMonkey脚本来动态地执行此操作,但对于快速的Hi-5来说,这听起来像是很多工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM