Skip to content

jiacai2050/jobbole

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 

Repository files navigation

Bookmarklet for Jobbole

本书签工具主要功能是方便用户向伯乐在线 | 头条分享文章,虽然官方也提供了浏览器扩展,个人觉得安装扩展显得有些“笨重”,而且最主要的是消耗系统资源。于是,参考 pocket一点黑科技,写了本书签工具,希望对大家有帮助。😊

使用方法

GitHub 出于某些原因,不允许在 README.md 里面使用 script 标签,内敛样式(inline-styles),所以我只能创建 GitHub Pages 来做安装演示。囧

开发过程

  1. 编写源代码

    javascript:(function() {
    var excerpt = window.getSelection ? window.getSelection().toString() : "";
    
    if(excerpt === "") {
        var meta = document.querySelector("meta[name=\'description\']");
        if(meta) {
            excerpt = meta.getAttribute("content");
        }
    }
    window.location="http://top.jobbole.com/submit/?utm_source=bookmark&utm_medium=toolBar&source="+encodeURIComponent(document.location)+"&title="+encodeURIComponent(document.title)+"&excerpt="+encodeURIComponent(excerpt);
    })()
  2. 为了防止旧版浏览器对 URL 中一些字符的兼容性,需要对源代码进行 encodeURIComponent,可使用开源中国在线编码转换

    需要注意的是,代码起始处的javascript:中的:不需要编码。

参考

About

伯乐头条文章分享书签

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published