分享文章的书签

Bookmarklet to share articles

我正在尝试创建一个 bookmarklet for my website 以在我的平台上自动分享文章。问题是没有提交文章

<div style="margin-left: 15px;"><span class="bookmarklet"><span class="fa fa-bookmark"></span> Get the
    <br>
    <a title="Drag this link to your bookmark bar. Click the bookmark when you want to submit an article." data-original-title="" class="has-tooltip" onclick="return false;" data-toggle="tooltip" data-placement="bottom" data-title="Drag this link to your bookmark bar. Click the bookmark when you want to submit an article." href="javascript:location.href='http://www.fineconomy.com/submit-articles/?link='+encodeURIComponent(location.href)+'&amp;title='+encodeURIComponent(document.title)" style="cursor:move;text-decoration:none;">FinEco Bookmarklet</a>
    </span>
</div>

我创建了一个测试用户:

用户名:测试

密码: test12345

对我做错了什么有什么建议吗?

感谢您的回复!

更新 1

我在页面底部添加了以下内容javascript。

;(function(win, $) {
if (window.location.pathname.indexOf('submit-articles') > -1) { 
    $(".maincontent").addClass('content-push-sidebar');
 } 
})(window, window.jQuery);

此外,我更新了小书签:

<span class="bookmarklet"><span class="fa fa-bookmark"></span> Get the<br>
<a title="Drag this link to your bookmark bar. Click the bookmark when you want to submit an article." data-original-title="" class="has-tooltip" onclick="return false;" data-toggle="tooltip" data-placement="bottom" data-title="Drag this link to your bookmark bar. Click the bookmark when you want to submit an article." href="javascript:location.href='http://www.fineconomy.com/submit-articles/?link='+encodeURIComponent(location.href)+'&amp;title='+encodeURIComponent(document.title)" style="cursor:move;text-decoration:none;">FinEco Bookmarklet</a></span>

我的问题是我无法向该字段添加主题。

当我关闭 submit-article window 时,会弹出带有主题的字段:

对于隐藏该字段的原因有什么建议吗?

重述问题以确保我理解:

您想要一个小书签,点击后会将用户带到 fineconomy 和 pre-fill 一个文章提交表单,其中包含 url 和用户碰巧访问的任何网页的标题。

到达 fineconomy 后,您添加的代码段通过检查页面 url(在 fineconomy 上)是否包含 "submit-articles" 来显示表单,如果包含,则基本上添加一个class 到主要内容 div 使表格出现。

因为您检查自己是否在 http://fineconomy.com/submit-articles/ 页面上,所以我假设您正在使用某种模板系统,该系统只允许您将脚本添加到某种全局页脚——可能是 wordpress,如果 wp-theme 引用。

无论如何,我认为主题字段被隐藏的原因是因为有这个css声明:

/* NEW CODE FOR V1.1 */

/** SNIP **/

.selectize-input{
    display:none;
}

主题字段是 .selectize-input 字段。我不确定为什么会出现这种样式,但它阻止了该字段的显示。我对您的系统了解不多,无法说明该声明是否属于那里。

如果它确实属于那里,我想您还必须增加页面上的 javascript 片段以显示该组件。像这样:

;(function(win, $) {
if (window.location.pathname.indexOf('submit-articles') > -1) { 
    $(".maincontent").addClass('content-push-sidebar');
    $(".selectize-input").show();
 } 
})(window, window.jQuery);

不过,您说当表单被关闭时该字段会出现,如果某些东西试图切换其可见性,则可能会发生这种情况 $(".selectize-input").toggle();。这表明提交表单通常是通过某种方法调用来显示的,如果是这种情况,建议使用此调用,而不是在中添加 content-push-sidebar class上面的片段。

如果可能,我还会检查是否有办法将片段仅放在 submit-page 上,而无需检查 "submit-article" 的当前 url。它通常会使事情更容易维护,更不容易出错,并且更有效率。