如果没有使用Greasemonkey的id,我将如何删除DIV
How would I remove a DIV if there are no IDs using Greasemonkey?
我想从页面中删除两个<div>
(隐藏和折叠空间)。
我最初打算使用Greasemonkey并根据ID删除-但这些似乎没有ID。其次,我假设iframe的内容发生了变化(因为这是一个内容横幅)。
我该如何让它们消失呢?:)
<div style="float: left; width: 700px; height:250px; margin-top:5px; margin-bottom:10px;">
<iframe src='http://www.therpf.com/banner-system/feature2.php' style='position:relative;top:0px;left:0px;height:272px;width:756px;' frameborder=0 scrolling='no'></iframe>
</div>
<div style="background: url('/images/styles/prometheus/black-30.png'); border:1px solid #333333; border-radius: 10px; float: right; margin-top:5px; margin-right: 2px; padding:10px 12px; width:300px; height: 250px;">
<!--Replica Movie Props – 9-->
<!--Screen Used Movie Props and Wardrobe - 45-->
<!--Replica Paper Props – 40-->
<!--Free Harry Paper Props – 64-->
<!--Sculpture and Makeup Effects – 62-->
<!--Replica Movie Costumes - 24-->
<!--Costume and Cosplay Showcase – 67-->
<!--Judge Dredd Costume Group – 71-->
<!--General Modeling - 11-->
<!--Studio Scale Models – 10-->
<!--Entertainment and Movie Talk – 47-->
<!--Conventions and Prop Parties – 68-->
<!--Off-Topic Talk – 12-->
<!--The Junkyard - 13-->
<iframe id='a9418415' name='a9418415' src='http://moviepropsites.com/ads/www/delivery/afr.php?zoneid=67&target=_blank' frameborder='0' scrolling='no' width='300' height='250'><a rel='nofollow' href='http://moviepropsites.com/ads/www/delivery/ck.php?n=a0516fad' target='_blank'><img src='http://moviepropsites.com/ads/www/delivery/avw.php?zoneid=67&n=a0516fad' border='0' alt='' /></a></iframe>
</div>
<div style="clear:both"></div>
基本上-我想删除两个主要的div,并将其替换为这个。
<div style="clear:both"></div>
任何帮助都将是非常感激的。
更新= = = = = = = =
其中一页的完整输出。我把它粘贴到pastebin上了。http://pastebin.com/s50tM8iU
第401-465行是我想要删除的,只留下第465行。
谢谢!
我们可能需要查看整个页面来为这些<div>
s制定健壮的选择器。
但是,如果它们总是包含具有src
属性的iframe,那么您可以使用这些iframe来查找不需要的内容。
列出坏框架src
属性中的关键文本片段。我也使用jQuery和waitForKeyElements()
,以防这个内容是由AJAX添加的。
// ==UserScript==
// @name _Remove bad divs containing bad iframes
// @include http://YOUR_SERVER.COM/YOUR_PATH/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant GM_addStyle
// ==/UserScript==
/*- The @grant directive is needed to work around a design change
introduced in GM 1.0. It restores the sandbox.
*/
var badFrameSrcSnips = [
//-- These are case-sensitive
"therpf.com/banner-system",
"moviepropsites.com/ads"
];
for (var J in badFrameSrcSnips) {
var srcSnippet = badFrameSrcSnips[J];
waitForKeyElements (
"iframe[src*='" + srcSnippet + "']", removeBadDiv
);
}
function removeBadDiv (jNode) {
//-- Replace the bad div (iframe's parent) with a tame one.
jNode.parent ().replaceWith ('<div style="clear:both"></div>');
}
相关文章:
- 使用php或javascript从facebook相册URL中删除多余的部分
- RegEx删除空属性?例如,如果(class=“”||class=“”)移除;否则就下课
- 如何删除多行HTML排列中的空白
- 如何从rails中的代码中删除新行( )
- 删除对HTML元素的拖动
- 当图像转换为本地存储的DataURL时,EXIF被删除
- 按顺序添加和删除类
- 从 DOM 中删除/删除 Javascript 用户定义的数组
- 命名函数“;删除“..删除是一个保留字
- 使用具有多个参数的猫鼬删除/删除
- 删除/删除 HTML 页面中的“:” 冒号
- 滚动条从何而来,如何删除它
- 如何删除/删除Firebase上的节点
- 我想,当我按下删除按钮删除删除按钮所代表的元素时
- 主干:查看删除/删除
- 删除/删除部分隐藏字段值的按钮单击
- Javascript从数据库中删除/删除表行
- 使用jQuery从HTML表中删除(删除)表行
- 删除删除ng网格中最后一行的功能
- 如何通过具有数组行的第一项的值来删除/删除 javascript 数组中的行